Skip to content

Commit

Permalink
Merge pull request #3833 from lucasallan/fixnum-bitlength
Browse files Browse the repository at this point in the history
Fixnum#bit_length - uses bit inversion when the value is negative
  • Loading branch information
headius committed Apr 28, 2016
2 parents 9176fc8 + 81ebc7e commit 85212ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyFixnum.java
Expand Up @@ -1194,7 +1194,7 @@ public IRubyObject succ(ThreadContext context) {
public IRubyObject bit_length(ThreadContext context) {
long tmpValue = value;
if (value < 0) {
tmpValue = Math.abs(value);
tmpValue = ~value;
}

return context.runtime.newFixnum(64 - Long.numberOfLeadingZeros(tmpValue));
Expand Down

0 comments on commit 85212ad

Please sign in to comment.