-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
In CRuby >= 2.1, both Fixnum and Bignum have #bit_length method. (Reference of Ruby 2.1 Bignum)
On the other hand, JRuby 9.0.x implements only Fixnum#bit_length, Bignum#bit_length is not implemented.
Java's BigInteger has bitLength method, so it can be polyfilled, but lacking CRuby's method is a problem.
# Polyfill code
class Bignum
def bit_length
to_java.bitLength
end
endEnvironment
- jruby 9.0.4.0 (2.2.2) 2015-11-12 b9fb7aa OpenJDK 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [linux-amd64]
- JRuby 9.0.5.0 (x64) on Windows7 x64
Expected Behavior
p (2**1000).respond_to?(:bit_length) # => true
p (2**1000).bit_length # => 1001Actual Behavior
p (2**1000).respond_to?(:bit_length) # => false
p (2**1000).bit_length # => raises NoMethodErrorReactions are currently unavailable