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

Integer exponentiation should avoid using floats #3163

Merged
merged 2 commits into from
Aug 18, 2016

Conversation

endSly
Copy link
Contributor

@endSly endSly commented Aug 16, 2016

Using float exponentiation generates error when working with long integers besides it's performance penalization.
Some examples:

61 ** 9 => 11694146092834141 # Expected 11694146092834140
126 ** 9 => 8004512848309156864 # Expected 8004512848309157376

Using Exponentiation by squaring it gives correct result.

@endSly endSly changed the title Integer exponentiation should avoid use float Integer exponentiation should avoid using floats Aug 16, 2016
@endSly
Copy link
Contributor Author

endSly commented Aug 16, 2016

It would be great to implement also Modular exponentiation

@ysbaddaden
Copy link
Contributor

I understand this is accurate as well as faster now?

@endSly
Copy link
Contributor Author

endSly commented Aug 17, 2016

In my benchmarks I've not seen great differences in term of performance. It will be very dependent on the processor...

@asterite
Copy link
Member

@endSly Thank you!!

@asterite asterite merged commit 2300f7c into crystal-lang:master Aug 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants