@Override public IRubyObject op_mod(ThreadContext context, long other) { if (other == 0) throw context.runtime.newZeroDivisionError(); BigInteger result = value.mod(long2big(other < 0 ? -other : other)); if (other < 0 && result.signum() != 0) result = long2big(other).add(result); return bignorm(context.runtime, result); }
@Override public IRubyObject op_mod(ThreadContext context, long other) { if (other == 0) throw context.runtime.newZeroDivisionError(); BigInteger result = value.mod(long2big(other < 0 ? -other : other)); if (other < 0 && result.signum() != 0) result = long2big(other).add(result); return bignorm(context.runtime, result); }
/** rb_int2big * */ public static BigInteger fix2big(RubyFixnum arg) { return long2big(arg.getLongValue()); }
/** rb_int2big * */ public static BigInteger fix2big(RubyFixnum arg) { return long2big(arg.getLongValue()); }
/** rb_int2big * */ public static BigInteger fix2big(RubyFixnum arg) { return long2big(arg.getLongValue()); }
/** rb_int2big * */ public static BigInteger fix2big(RubyFixnum arg) { return long2big(arg.getLongValue()); }
@Override public IRubyObject idiv(ThreadContext context, long other) { return divideImpl(context.runtime, long2big(other)); }
@Override public final IRubyObject op_mul(ThreadContext context, long other) { return bignorm(context.runtime, value.multiply(long2big(other))); }
public IRubyObject op_div(ThreadContext context, long other) { return divideImpl(context.runtime, long2big(other)); }
@Override public final IRubyObject op_mul(ThreadContext context, long other) { return bignorm(context.runtime, value.multiply(long2big(other))); }
@Override public IRubyObject idiv(ThreadContext context, long other) { return divideImpl(context.runtime, long2big(other)); }
public IRubyObject op_div(ThreadContext context, long other) { return divideImpl(context.runtime, long2big(other)); }
public IRubyObject op_mul(ThreadContext context, long other) { Ruby runtime = context.runtime; BigInteger result = value.multiply(long2big(other)); return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result); }
public IRubyObject op_mul(ThreadContext context, long other) { Ruby runtime = context.runtime; BigInteger result = value.multiply(long2big(other)); return result.signum() == 0 ? RubyFixnum.zero(runtime) : new RubyBignum(runtime, result); }
bigBase = ((RubyBignum) base).getValue(); } else { bigBase = long2big( ((RubyFixnum) base).getLongValue() );
bigBase = ((RubyBignum) base).getValue(); } else { bigBase = long2big( ((RubyFixnum) base).getLongValue() );
private IRubyObject powerOther(ThreadContext context, IRubyObject other) { final Ruby runtime = context.runtime; final long a = this.value; if (other instanceof RubyBignum) { if (sites(context).op_lt_bignum.call(context, other, other, RubyFixnum.zero(runtime)).isTrue()) { RubyRational rational = RubyRational.newRationalRaw(runtime, this); return numFuncall(context, rational, sites(context).op_exp_rational, other); } if (a == 0) return RubyFixnum.zero(runtime); if (a == 1) return RubyFixnum.one(runtime); if (a == -1) { return ((RubyBignum) other).even_p(context).isTrue() ? RubyFixnum.one(runtime) : RubyFixnum.minus_one(runtime); } return RubyBignum.newBignum(runtime, RubyBignum.long2big(a)).op_pow(context, other); } if (other instanceof RubyFloat) { double b = ((RubyFloat)other).getValue(); if (b == 0.0 || a == 1) return runtime.newFloat(1.0); if (a == 0) return runtime.newFloat(b < 0 ? 1.0 / 0.0 : 0.0); return RubyFloat.newFloat(runtime, Math.pow(a, b)); } return coerceBin(context, sites(context).op_exp, other); }
private IRubyObject powerOther(ThreadContext context, IRubyObject other) { final Ruby runtime = context.runtime; final long a = this.value; if (other instanceof RubyBignum) { if (sites(context).op_lt_bignum.call(context, other, other, RubyFixnum.zero(runtime)).isTrue()) { RubyRational rational = RubyRational.newRationalRaw(runtime, this); return numFuncall(context, rational, sites(context).op_exp_rational, other); } if (a == 0) return RubyFixnum.zero(runtime); if (a == 1) return RubyFixnum.one(runtime); if (a == -1) { return ((RubyBignum) other).even_p(context).isTrue() ? RubyFixnum.one(runtime) : RubyFixnum.minus_one(runtime); } return RubyBignum.newBignum(runtime, RubyBignum.long2big(a)).op_pow(context, other); } if (other instanceof RubyFloat) { double b = ((RubyFloat)other).getValue(); if (b == 0.0 || a == 1) return runtime.newFloat(1.0); if (a == 0) return runtime.newFloat(b < 0 ? 1.0 / 0.0 : 0.0); return RubyFloat.newFloat(runtime, Math.pow(a, b)); } return coerceBin(context, sites(context).op_exp, other); }