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

Initial pass at pow(Self, Int) for Float and Double #83

Merged
merged 4 commits into from
Nov 30, 2019

Conversation

stephentyrone
Copy link
Member

More clever implementation is certainly possible (and desired in the long-term), but this basically gets us to the desired semantics without undue performance penalty for the common use cases.

These are the hardest cases to get right; most of the fail at present.

Also some improvements to sanityCheck to handle negative values correctly and treat infinity as the next binade up (which isn't ideal for general use, but is good for this sort of rough testing.)
We don't need to do anything special for Float80, but Float and Double require some handholding because Int values are not always representable.
Also skip out of tests that won't compile and wouldn't make sense anyway on 32b systems.
@stephentyrone stephentyrone merged commit 7ff707f into apple:master Nov 30, 2019
@stephentyrone stephentyrone deleted the pown branch November 30, 2019 04:13
@NevinBR
Copy link
Contributor

NevinBR commented Nov 30, 2019

Very nice. It might be worth mentioning that the Float and Double versions will both work properly on hypothetical future platforms where Int is more than 64 bits (because all |x| != 1 will overflow or underflow before n saturates 63 bits), but the Float80 version will not.

…or it might not be worth mentioning.

@stephentyrone
Copy link
Member Author

stephentyrone commented Nov 30, 2019

On a hypothetical future platform where Int is more than 64 bits:

  • Float80 doesn't exist, because it's only available on i386 and x86_64.
  • swift itself will have a whole bunch of issues.
  • the tests will immediately start failing if Float80 does somehow exist.

So this is mostly theoretical. But I'll add a note anyway =)

@stephentyrone
Copy link
Member Author

This change (without the note) is tagged as 0.0.3.

Copy link

@Dindin1992 Dindin1992 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

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.

3 participants