Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bddad4cd48bf
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9b630363442d
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Apr 27, 2016

  1. Copy the full SHA
    8da72df View commit details
  2. Merge pull request #3831 from lucasallan/Fixnum-bit_length

    Fixes Fixnum#bit_length when the value is negative.
    kares committed Apr 27, 2016
    Copy the full SHA
    9b63036 View commit details
Showing with 6 additions and 1 deletion.
  1. +6 −1 core/src/main/java/org/jruby/RubyFixnum.java
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -1192,7 +1192,12 @@ public IRubyObject succ(ThreadContext context) {

@JRubyMethod
public IRubyObject bit_length(ThreadContext context) {
return context.runtime.newFixnum(64 - Long.numberOfLeadingZeros(value));
long tmpValue = value;
if (value < 0) {
tmpValue = Math.abs(value);
}

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

@Override