Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7056] Float(exactly: Int32) and Double(exactly: Int64) do not work properly #49604

Closed
swift-ci opened this issue Feb 22, 2018 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7056
Radar None
Original Reporter dBoetius (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

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
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 4dd9d304e05312ef37912846c52af49c

duplicates:

  • SR-4634 Error in exact floating point initializers

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.

@belkadan
Copy link
Contributor

cc @moiseev, @stephentyrone

@stephentyrone
Copy link
Member

I think @natecook1000 fixed this already?

@xwu
Copy link
Collaborator

xwu commented Feb 23, 2018

Indeed, this is already fixed in Xcode 9.3/Swift 4.1 beta (by @natecook1000's PR #12739).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

4 participants