[SR-491] Double#description is not roundtrip-safe #43108
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
CustomStringConvertible
Area → standard library: The `CustomStringConvertible` protocol
Double
Area → standard library: The `Double` type
duplicate
Resolution: Duplicates another issue
standard library
Area: Standard library umbrella
unexpected behavior
Bug: Unexpected behavior or incorrect output
Uh oh!
There was an error while loading. Please reload this page.
Attachment: Download
Additional Detail from JIRA
md5: 1c1d9ebdc5e0745501c97e00c87b6dc7
duplicates:
Issue Description:
In order to stringily a double roundtrip-safe, we need up to 17 decimal digits. But Double#description
of current Swift (on all platforms) gives us one digit short.
http://swiftlang.ng.bluemix.net/#/repl/937bf49dd2f110c6f4c0fd942de051d734b3e051887b1c6b762c39e2c7956146
As you see in the attached screenshot, Playground is okay. So is REPL.
Perl 5 and Python 2 have the same symptom:
Perl 5 http://ideone.com/J7kVwv
Python 2 https://repl.it/BcF7/0
While most other modern languages do not:
Java http://ideone.com/OSeb5S
JavaScript http://ideone.com/qonDEO
Python 3 https://repl.it/BcFb/0
Ruby http://ideone.com/BrfiBO
IMHO this is rather an undocumented feature than a bug but with JSON so ubiquitous and all of its numbers are doubles, we should make Double#description roundtrip-safe.
The text was updated successfully, but these errors were encountered: