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: 3a91f9e7d35c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 63c5d872f7ea
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 6, 2017

  1. Copy the full SHA
    75f0aef View commit details
  2. Copy the full SHA
    63c5d87 View commit details
Showing with 23 additions and 20 deletions.
  1. +17 −15 core/src/main/java/org/jruby/RubyRational.java
  2. +6 −5 core/src/main/java/org/jruby/util/Numeric.java
32 changes: 17 additions & 15 deletions core/src/main/java/org/jruby/RubyRational.java
Original file line number Diff line number Diff line change
@@ -747,45 +747,47 @@ public IRubyObject op_coerce(ThreadContext context, IRubyObject other) {
/** nurat_idiv
*
*/
public IRubyObject op_idiv(ThreadContext context, IRubyObject other) {
return op_idiv19(context, other);
}

@JRubyMethod(name = "div")
public IRubyObject op_idiv19(ThreadContext context, IRubyObject other) {
public IRubyObject op_idiv(ThreadContext context, IRubyObject other) {
if (num2dbl(other) == 0.0) throw context.runtime.newZeroDivisionError();

return f_floor(context, f_div(context, this, other));
}

@Deprecated
public IRubyObject op_idiv19(ThreadContext context, IRubyObject other) {
return op_idiv(context, other);
}

/** nurat_mod
*
*/
public IRubyObject op_mod(ThreadContext context, IRubyObject other) {
return op_mod19(context, other);
}

@JRubyMethod(name = {"modulo", "%"})
public IRubyObject op_mod19(ThreadContext context, IRubyObject other) {
public IRubyObject op_mod(ThreadContext context, IRubyObject other) {
if (num2dbl(other) == 0.0) throw context.runtime.newZeroDivisionError();

return f_sub(context, this, f_mul(context, other, f_floor(context, f_div(context, this, other))));
}

@Deprecated
public IRubyObject op_mod19(ThreadContext context, IRubyObject other) {
return op_mod(context, other);
}

/** nurat_divmod
*
*/
public IRubyObject op_divmod(ThreadContext context, IRubyObject other) {
return op_divmod19(context, other);
}

@JRubyMethod(name = "divmod")
public IRubyObject op_divmod19(ThreadContext context, IRubyObject other) {
public IRubyObject op_divmod(ThreadContext context, IRubyObject other) {
if (num2dbl(other) == 0.0) throw context.runtime.newZeroDivisionError();

IRubyObject val = f_floor(context, f_div(context, this, other));
return context.runtime.newArray(val, f_sub(context, this, f_mul(context, other, val)));
}

@Deprecated
public IRubyObject op_divmod19(ThreadContext context, IRubyObject other) {
return op_divmod(context, other);
}

/** nurat_rem
11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/util/Numeric.java
Original file line number Diff line number Diff line change
@@ -350,24 +350,25 @@ public static boolean f_zero_p(ThreadContext context, IRubyObject x) {
*
*/
public static boolean f_one_p(ThreadContext context, IRubyObject x) {
if (x instanceof RubyFixnum) return ((RubyFixnum)x).getLongValue() == 1;
if (x instanceof RubyFixnum) return ((RubyFixnum) x).getLongValue() == 1;
return sites(context).op_equals.call(context, x, x, RubyFixnum.one(context.runtime)).isTrue();
}

/** f_minus_one_p
*
*/
public static boolean f_minus_one_p(ThreadContext context, IRubyObject x) {
if (x instanceof RubyFixnum) return ((RubyFixnum)x).getLongValue() == -1;
if (x instanceof RubyFixnum) return ((RubyFixnum) x).getLongValue() == -1;
return sites(context).op_equals.call(context, x, x, RubyFixnum.minus_one(context.runtime)).isTrue();
}

/** f_odd_p
*
*/
public static boolean f_odd_p(ThreadContext context, IRubyObject integer) {
Ruby runtime = context.runtime;
return (((RubyFixnum) sites(context).op_mod.call(context, integer, integer, RubyFixnum.two(runtime))).getLongValue() != 0);
public static boolean f_odd_p(ThreadContext context, IRubyObject i) {
if (i instanceof RubyFixnum) return ((RubyFixnum) i).getLongValue() % 2 != 0;
RubyFixnum two = RubyFixnum.two(context.runtime);
return (((RubyFixnum) sites(context).op_mod.call(context, i, i, two)).getLongValue() != 0);
}

/** i_gcd