You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fd48f2c
Browse filesBrowse the repository at this point in the historyBrowse files
Integer divmod/remainder/gcd/lcm/gcdlcm accept Bignum and Float operands (#466)
The Integer division family coerced both operands through int64, so a Bignum
receiver or argument raised a spurious RangeError ("bignum too big to convert
into 'long'") or a TypeError, and a Float argument to divmod/remainder was
rejected outright.
They now compute in math/big when either side is a Bignum:
- divmod / gcdlcm are floored, matching MRI's sign-of-divisor modulo.
- remainder truncates toward zero.
- gcd / lcm / gcdlcm accept any Integer/Bignum, raise "not an integer" for a
Float or non-integer, and treat gcd(0,0) as 0.
- divmod / remainder accept a Float argument (Integer quotient, Float modulo),
run the coerce protocol for a non-numeric argument that offers #coerce, and
otherwise raise the canonical "X can't be coerced into Integer"; division by
zero still raises ZeroDivisionError, including for a Bignum receiver.
The now-unused int64 helpers (gcdInt / absInt / bigArg) are removed.
Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
floor rises 15750 -> 15770 (language+core now 15834 passing, +19).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments