You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift 4.2 uses a new algorithm that should always print a minimal-length decimal value that parses back into the original floating-point value, so Double(String( x )) always produces x.
I noticed that the REPL still uses the old algorithm:
$ swift
Welcome to Apple Swift version 4.2 (swiftlang-1000.0.36 clang-1000.0.4). Type :help for assistance.
1> 0.3
$R0: Double = 0.29999999999999999
2> 0.3.debugDescription
$R1: String = "0.3"
Just for completion, here is the same session with Swift 4.1, where the old algorithm was used not only for the REPL's feedback but also for eg the result of 0.3.debugDescription:
$ swift
Welcome to Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2). Type :help for assistance.
1> 0.3
$R0: Double = 0.29999999999999999
2> 0.3.debugDescription
$R1: String = "0.29999999999999999"
The text was updated successfully, but these errors were encountered:
lldb uses APFloat API's to print doubles and floats. Does the swift printing use that or something layered on top of that? If the former it should be pretty easy to include whatever flags you use to get this behavior out of APFloat. If the latter, we should move this code somewhere in llvm so lldb doesn't have to reimplement it.
Additional Detail from JIRA
md5: 8dd91e31acdf34ed560b155632235ce2
Issue Description:
Filing this as suggested by @jckarter in this forum post.
Swift 4.2 uses a new algorithm that should always print a minimal-length decimal value that parses back into the original floating-point value, so Double(String( x )) always produces x.
I noticed that the REPL still uses the old algorithm:
Just for completion, here is the same session with Swift 4.1, where the old algorithm was used not only for the REPL's feedback but also for eg the result of 0.3.debugDescription:
The text was updated successfully, but these errors were encountered: