Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upInteger division doesn't work with left operands larger than LONG_MAX #92
Comments
sleeparrow
referenced this issue
Jan 11, 2015
Closed
Flooring division (//) incorrect for big numbers #878
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
int-index
Apr 21, 2015
I have encountered this bug and my workaround was to define my own integer division:
(//) : Int -> Int -> Int
a // b = floor (Basics.toFloat a / Basics.toFloat b)Is there a better implementation?
int-index
commented
Apr 21, 2015
|
I have encountered this bug and my workaround was to define my own integer division: (//) : Int -> Int -> Int
a // b = floor (Basics.toFloat a / Basics.toFloat b)Is there a better implementation? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
evancz
Sep 22, 2016
Member
Consolidated all the math related stuff into the #721 meta issue. Follow along there!
|
Consolidated all the math related stuff into the #721 meta issue. Follow along there! |
evancz
closed this
Sep 22, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mischa-Alff commentedJan 11, 2015
The issue at elm-compiler#878 mentions it, but it's in the wrong repo, so I'm recreating it here.
LHS arguments greater than
LONG_MAX(4294967295) return a negative number when using integer division (//).This is because elm-core's
src/Native/Basics.jsdivfunction isa/b|0, thus using JavaScript's OR operator, which most converts the LHS to a 32-bit integer and returns a 32-bit integer.EDIT: I read the JS spec, it's not a bug with JS, just another one of its problems.