@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)); }
@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)); }
/** * rb_big_divide. Shared part for both "/" and "div" operations. */ private IRubyObject op_divide(ThreadContext context, IRubyObject other, boolean slash) { Ruby runtime = context.runtime; final BigInteger otherValue; if (other instanceof RubyFixnum) { otherValue = fix2big((RubyFixnum) other); } else if (other instanceof RubyBignum) { otherValue = ((RubyBignum) other).value; } else if (other instanceof RubyFloat) { double otherFloatValue = ((RubyFloat) other).getDoubleValue(); if (!slash) { if (otherFloatValue == 0.0) throw runtime.newZeroDivisionError(); } double div = big2dbl(this) / otherFloatValue; if (slash) { return RubyFloat.newFloat(runtime, div); } else { return RubyNumeric.dbl2ival(runtime, div); } } else { return coerceBin(context, slash ? sites(context).op_quo : sites(context).div, other); } return divideImpl(runtime, otherValue); }
/** * rb_big_divide. Shared part for both "/" and "div" operations. */ private IRubyObject op_divide(ThreadContext context, IRubyObject other, boolean slash) { Ruby runtime = context.runtime; final BigInteger otherValue; if (other instanceof RubyFixnum) { otherValue = fix2big((RubyFixnum) other); } else if (other instanceof RubyBignum) { otherValue = ((RubyBignum) other).value; } else if (other instanceof RubyFloat) { double otherFloatValue = ((RubyFloat) other).getDoubleValue(); if (!slash) { if (otherFloatValue == 0.0) throw runtime.newZeroDivisionError(); } double div = big2dbl(this) / otherFloatValue; if (slash) { return RubyFloat.newFloat(runtime, div); } else { return RubyNumeric.dbl2ival(runtime, div); } } else { return coerceBin(context, slash ? sites(context).op_quo : sites(context).div, other); } return divideImpl(runtime, otherValue); }