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

Change the overflow behavior of floating-point inits from String #25313

Closed

Conversation

stephentyrone
Copy link
Member

All other floating-point inits round out-of-range inputs to the nearest representable value. The conversions from string currently do not match this behavior, and return nil instead. This change makes it so only invalid character sequences produce nil; with overflow producing infinity and underflow producing zero, matching the behavior of literals.

Fixes rdar://problem/36990878

All other floating-point inits round out-of-range inputs to the nearest representable value. The conversions from string currently do not match this behavior, and return nil instead. This change makes it so only invalid character sequences produce nil; with overflow producing infinity and underflow producing zero, matching the behavior of literals.
@stephentyrone
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - d72f61d

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 8, 2019

Build failed
Swift Test OS X Platform
Git Sha - d72f61d

@stephentyrone
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test Linux Platform
Git Sha - d72f61d

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - d72f61d

@stephentyrone
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test Linux Platform
Git Sha - d72f61d

@stephentyrone
Copy link
Member Author

@swift-ci please test linux

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - d72f61d

@palimondo
Copy link
Collaborator

@swift-ci please test linux platform

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 2, 2019

Build failed
Swift Test Linux Platform
Git Sha - d72f61d

@stephentyrone
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Collaborator

Build failed
Swift Test Linux Platform
Git Sha - d72f61d

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@stephentyrone stephentyrone deleted the overflow-underflow-nonnil branch October 1, 2020 13:15
tbkka added a commit to tbkka/swift that referenced this pull request Oct 16, 2020
…infinity

Previously, overflow and underflow both caused this to return `nil`, which causes several problems:
* It does not distinguish between a large but valid input and a malformed input.  `Float("3.402824e+38")` is perfectly well-formed but returns nil
* It differs from how the compiler handles literals.  As a result, `Float(3.402824e+38)` is very different from `Float("3.402824e+38")`
* It's inconsistent with Foundation Scanner()
* It's inconsistent with other programming languages

This is exactly the same as apple#25313

Fixes rdar://problem/36990878
stephentyrone pushed a commit that referenced this pull request Oct 19, 2020
…infinity (#34339)

Previously, overflow and underflow both caused this to return `nil`, which causes several problems:
* It does not distinguish between a large but valid input and a malformed input.  `Float("3.402824e+38")` is perfectly well-formed but returns nil
* It differs from how the compiler handles literals.  As a result, `Float(3.402824e+38)` is very different from `Float("3.402824e+38")`
* It's inconsistent with Foundation Scanner()
* It's inconsistent with other programming languages

This is exactly the same as #25313

Fixes rdar://problem/36990878
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants