[SR-7056] Float(exactly: Int32) and Double(exactly: Int64) do not work properly #49604
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Attachment: Download
Environment
Xcode Version 9.2 (9C40b) on macOS 10.13.3,
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: 4dd9d304e05312ef37912846c52af49c
duplicates:
Issue Description:
If calling Float(exactly: ) with an Int32 value or Double(exactly: ) with an Int64 value, that should not be convertible, it very often returns a floating point value that isn't equal to the initial int value. (As fas as I can see, the value get's rounded to the next representable value).
I have indeed not found a case where this initialiser returned nil.
I added two Playgrounds (one for Float, one for Double) that give a few examples of this behaviour.
I can't tell, whether this is really related to swift itself.
The text was updated successfully, but these errors were encountered: