@Override public IRubyObject op_div(ThreadContext context, IRubyObject other) { return idiv(context, other, sites(context).op_quo); }
private IRubyObject op_leOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBoolean.newBoolean(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value) <= 0); } if (other instanceof RubyFloat) { return RubyBoolean.newBoolean(context.runtime, (double) value <= ((RubyFloat) other).getDoubleValue()); } return coerceRelOp(context, sites(context).op_le, other); }
private IRubyObject op_gtOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBoolean.newBoolean(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value) > 0); } if (other instanceof RubyFloat) { return RubyBoolean.newBoolean(context.runtime, (double) value > ((RubyFloat) other).getDoubleValue()); } return coerceRelOp(context, sites(context).op_gt, other); }
private IRubyObject op_geOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBoolean.newBoolean(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value) >= 0); } if (other instanceof RubyFloat) { return RubyBoolean.newBoolean(context.runtime, (double) value >= ((RubyFloat) other).getDoubleValue()); } return coerceRelOp(context, sites(context).op_ge, other); }
private IRubyObject op_geOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBoolean.newBoolean(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value) >= 0); } if (other instanceof RubyFloat) { return RubyBoolean.newBoolean(context.runtime, (double) value >= ((RubyFloat) other).getDoubleValue()); } return coerceRelOp(context, sites(context).op_ge, other); }
private IRubyObject op_ltOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBoolean.newBoolean(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value) < 0); } if (other instanceof RubyFloat) { return RubyBoolean.newBoolean(context.runtime, (double) value < ((RubyFloat) other).getDoubleValue()); } return coerceRelOp(context, sites(context).op_lt, other); }
private IRubyObject compareOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return newFixnum(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value)); } if (other instanceof RubyFloat) { return dbl_cmp(context.runtime, (double) value, ((RubyFloat) other).getDoubleValue()); } return coerceCmp(context, sites(context).op_cmp, other); }
private IRubyObject op_ltOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBoolean.newBoolean(context.runtime, BigInteger.valueOf(value).compareTo(((RubyBignum) other).value) < 0); } if (other instanceof RubyFloat) { return RubyBoolean.newBoolean(context.runtime, (double) value < ((RubyFloat) other).getDoubleValue()); } return coerceRelOp(context, sites(context).op_lt, 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); }
private int compareToOther(IRubyObject other) { if (other instanceof RubyBignum) return BigInteger.valueOf(value).compareTo(((RubyBignum) other).value); if (other instanceof RubyFloat) return Double.compare((double)value, ((RubyFloat)other).getDoubleValue()); ThreadContext context = getRuntime().getCurrentContext(); return (int) coerceCmp(context, sites(context).op_cmp, other).convertToInteger().getLongValue(); }
private int compareToOther(IRubyObject other) { if (other instanceof RubyBignum) return BigInteger.valueOf(value).compareTo(((RubyBignum) other).value); if (other instanceof RubyFloat) return Double.compare((double)value, ((RubyFloat)other).getDoubleValue()); ThreadContext context = getRuntime().getCurrentContext(); return (int) coerceCmp(context, sites(context).op_cmp, other).convertToInteger().getLongValue(); }
/** 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_and * */ @Override public IRubyObject op_and(ThreadContext context, IRubyObject other) { if (other instanceof RubyFixnum) { return context.runtime.newFixnum(value & ((RubyFixnum) other).value); } if (other instanceof RubyBignum) { return ((RubyBignum) other).op_and(context, this); } return coerceBit(context, sites(context).checked_op_and, other); }
private IRubyObject multiplyOther(ThreadContext context, IRubyObject other) { Ruby runtime = context.runtime; if (other instanceof RubyBignum) { return ((RubyBignum) other).op_mul(context, this.value); } if (other instanceof RubyFloat) { return runtime.newFloat((double) value * ((RubyFloat) other).getDoubleValue()); } return coerceBin(context, sites(context).op_times, other); }
private IRubyObject multiplyOther(ThreadContext context, IRubyObject other) { Ruby runtime = context.runtime; if (other instanceof RubyBignum) { return ((RubyBignum) other).op_mul(context, this.value); } if (other instanceof RubyFloat) { return runtime.newFloat((double) value * ((RubyFloat) other).getDoubleValue()); } return coerceBin(context, sites(context).op_times, other); }
private IRubyObject addOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return ((RubyBignum) other).op_plus(context, this.value); } if (other instanceof RubyFloat) { return context.runtime.newFloat((double) value + ((RubyFloat) other).getDoubleValue()); } return coerceBin(context, sites(context).op_plus, other); }
@Override public IRubyObject isPositive(ThreadContext context) { Ruby runtime = context.runtime; CachingCallSite op_gt_site = sites(context).basic_op_gt; if (op_gt_site.retrieveCache(metaClass).method.isBuiltin()) { return runtime.newBoolean(value > 0); } return op_gt_site.call(context, this, this, RubyFixnum.zero(runtime)); }
private IRubyObject subtractOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBignum.newBignum(context.runtime, value).op_minus(context, ((RubyBignum) other).value); } if (other instanceof RubyFloat) { return context.runtime.newFloat((double) value - ((RubyFloat) other).getDoubleValue()); } return coerceBin(context, sites(context).op_minus, other); }
private IRubyObject subtractOther(ThreadContext context, IRubyObject other) { if (other instanceof RubyBignum) { return RubyBignum.newBignum(context.runtime, value).op_minus(context, ((RubyBignum) other).value); } if (other instanceof RubyFloat) { return context.runtime.newFloat((double) value - ((RubyFloat) other).getDoubleValue()); } return coerceBin(context, sites(context).op_minus, other); }
@Override public IRubyObject isNegative(ThreadContext context) { Ruby runtime = context.runtime; CachingCallSite op_lt_site = sites(context).basic_op_lt; if (op_lt_site.retrieveCache(metaClass).method.isBuiltin()) { return runtime.newBoolean(value < 0); } return op_lt_site.call(context, this, this, RubyFixnum.zero(runtime)); }