/** fix_div * here is terrible MRI gotcha: * 1.div 3.0 -> 0 * 1 / 3.0 -> 0.3333333333333333 * * MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: * rb_funcall(x, ruby_frame->orig_func, 1, y); * * also note that RubyFloat doesn't override Numeric.div */ @JRubyMethod(name = "div") public IRubyObject div_div(ThreadContext context, IRubyObject other) { if (context.is19) checkZeroDivisionError(context, other); return idiv(context, other, "div"); }
/** fix_div * here is terrible MRI gotcha: * 1.div 3.0 -> 0 * 1 / 3.0 -> 0.3333333333333333 * * MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: * rb_funcall(x, ruby_frame->orig_func, 1, y); * * also note that RubyFloat doesn't override Numeric.div */ @JRubyMethod(name = "div") public IRubyObject div_div(ThreadContext context, IRubyObject other) { if (context.is19) checkZeroDivisionError(context, other); return idiv(context, other, "div"); }
/** fix_div * here is terrible MRI gotcha: * 1.div 3.0 -> 0 * 1 / 3.0 -> 0.3333333333333333 * * MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: * rb_funcall(x, ruby_frame->orig_func, 1, y); * * also note that RubyFloat doesn't override Numeric.div */ @Override public IRubyObject idiv(ThreadContext context, IRubyObject other) { checkZeroDivisionError(context, other); return idiv(context, other, sites(context).div); }
/** fix_div * here is terrible MRI gotcha: * 1.div 3.0 -> 0 * 1 / 3.0 -> 0.3333333333333333 * * MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: * rb_funcall(x, ruby_frame->orig_func, 1, y); * * also note that RubyFloat doesn't override Numeric.div */ @Override public IRubyObject idiv(ThreadContext context, IRubyObject other) { checkZeroDivisionError(context, other); return idiv(context, other, sites(context).div); }
/** fix_mod * */ @Override public IRubyObject op_mod(ThreadContext context, IRubyObject other) { checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return moduloFixnum(context, (RubyFixnum) other); } return coerceBin(context, sites(context).op_mod, other); }
/** fix_divmod * */ @Override public IRubyObject divmod(ThreadContext context, IRubyObject other) { checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return divmodFixnum(context, (RubyFixnum) other); } return coerceBin(context, sites(context).divmod, other); }
/** fix_divmod * */ @Override public IRubyObject divmod(ThreadContext context, IRubyObject other) { checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return divmodFixnum(context, (RubyFixnum) other); } return coerceBin(context, sites(context).divmod, other); }
/** fix_mod * */ @Override public IRubyObject op_mod(ThreadContext context, IRubyObject other) { checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return moduloFixnum(context, (RubyFixnum) other); } return coerceBin(context, sites(context).op_mod, other); }
/** fix_divmod * */ @JRubyMethod(name = "divmod") @Override public IRubyObject divmod(ThreadContext context, IRubyObject other) { if (context.runtime.is1_9()) checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return divmodFixnum(context, other); } return coerceBin(context, "divmod", other); }
/** fix_mod * */ @JRubyMethod(name = {"%", "modulo"}) public IRubyObject op_mod(ThreadContext context, IRubyObject other) { if (context.runtime.is1_9()) checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return moduloFixnum(context, (RubyFixnum)other); } return coerceBin(context, "%", other); }
/** fix_divmod * */ @JRubyMethod(name = "divmod") @Override public IRubyObject divmod(ThreadContext context, IRubyObject other) { if (context.runtime.is1_9()) checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return divmodFixnum(context, other); } return coerceBin(context, "divmod", other); }
/** fix_mod * */ @JRubyMethod(name = {"%", "modulo"}) public IRubyObject op_mod(ThreadContext context, IRubyObject other) { if (context.runtime.is1_9()) checkZeroDivisionError(context, other); if (other instanceof RubyFixnum) { return moduloFixnum(context, (RubyFixnum)other); } return coerceBin(context, "%", other); }