public IRubyObject op_div(ThreadContext context, long other) { return idiv(context, other, "/"); }
public IRubyObject op_div(ThreadContext context, long other) { return idiv(context, other, "/"); }
@Override public IRubyObject op_div(ThreadContext context, IRubyObject other) { return idiv(context, other, sites(context).op_quo); }
@Override public IRubyObject op_div(ThreadContext context, IRubyObject other) { return idiv(context, other, sites(context).op_quo); }
@JRubyMethod(name = "/") public IRubyObject op_div(ThreadContext context, IRubyObject other) { return idiv(context, other, "/"); }
@JRubyMethod(name = "/") public IRubyObject op_div(ThreadContext context, IRubyObject other) { return idiv(context, other, "/"); }
/** 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 */ @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 */ @JRubyMethod(name = "div") public IRubyObject div_div(ThreadContext context, IRubyObject other) { if (context.is19) checkZeroDivisionError(context, other); return idiv(context, other, "div"); }
private static RubyNumeric canonicalizeInternal(ThreadContext context, RubyClass clazz, long num, long den) { if (den == 0) throw context.runtime.newZeroDivisionError(); if (num == Long.MIN_VALUE && den == Long.MIN_VALUE) canonicalizeInternal(context, clazz, context.runtime.newFixnum(num), context.runtime.newFixnum(den)); long gcd = i_gcd(num, den); RubyInteger _num = (RubyInteger) context.runtime.newFixnum(num).idiv(context, gcd); RubyInteger _den = (RubyInteger) context.runtime.newFixnum(den).idiv(context, gcd); if (Numeric.CANON && canonicalization && _den.getLongValue() == 1) return _num; return newRational(context.runtime, clazz, _num, _den); }
private static RubyNumeric canonicalizeInternal(ThreadContext context, RubyClass clazz, long num, long den) { if (den == 0) throw context.runtime.newZeroDivisionError(); if (num == Long.MIN_VALUE && den == Long.MIN_VALUE) canonicalizeInternal(context, clazz, context.runtime.newFixnum(num), context.runtime.newFixnum(den)); long gcd = i_gcd(num, den); RubyInteger _num = (RubyInteger) context.runtime.newFixnum(num).idiv(context, gcd); RubyInteger _den = (RubyInteger) context.runtime.newFixnum(den).idiv(context, gcd); if (Numeric.CANON && canonicalization && _den.getLongValue() == 1) return _num; return newRational(context.runtime, clazz, _num, _den); }