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
According to CRuby manual, Fixnum#bit_length returns "the bit position of the highest bit which is different to the sign bit". In other words, check 0 bit position for negative numbers.
Fixnum#bit_length
In JRuby implementation it returns 64 - Long.numberOfLeadingZeros(value).
64 - Long.numberOfLeadingZeros(value)
Long.numberOfLeadingZeros(value) returns 0 if value is negative, so the value is fixed to 64 in the cases.
Long.numberOfLeadingZeros(value)
value
p (-1).bit_length # => 0
p (-1).bit_length # => 64
The text was updated successfully, but these errors were encountered:
No branches or pull requests
According to CRuby manual,
Fixnum#bit_length
returns "the bit position of the highest bit which is different to the sign bit". In other words, check 0 bit position for negative numbers.In JRuby implementation it returns
64 - Long.numberOfLeadingZeros(value)
.Long.numberOfLeadingZeros(value)
returns 0 ifvalue
is negative, so the value is fixed to 64 in the cases.Environment
Expected Behavior
Actual Behavior
The text was updated successfully, but these errors were encountered: