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

multiplication is not checked by default for overflow #5054

Closed
StefanKarpinski opened this issue Dec 7, 2013 · 3 comments
Closed

multiplication is not checked by default for overflow #5054

StefanKarpinski opened this issue Dec 7, 2013 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@StefanKarpinski
Copy link
Member

julia> 128738872312*invmod(128738872312,9223372036854775783)
9223369465230597584

julia> ans < 9223372036854775783
true
@vtjnash vtjnash added this to the 0.4 milestone Apr 25, 2014
@skariel
Copy link
Contributor

skariel commented Sep 20, 2014

You are overflowing the invmod return value, which is an Int64. The following works good:

BigInt(128738872312)*invmod(128738872312,9223372036854775783)

so, this is no bug I guess :)

@vtjnash
Copy link
Member

vtjnash commented Aug 26, 2015

julia> Base.checked_mul(128738872312, invmod(128738872312,9223372036854775783))
ERROR: OverflowError()
 in checked_mul at int.jl:514

@vtjnash vtjnash changed the title invmod: incorrect for large moduli multiplication is not checked by default for overflow Aug 26, 2015
@vtjnash
Copy link
Member

vtjnash commented Aug 26, 2015

duplicate of #855

@vtjnash vtjnash closed this as completed Aug 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants