/** flo_quo * */ @JRubyMethod(name = {"quo", "fdiv"}) public IRubyObject quo(ThreadContext context, IRubyObject other) { return numFuncall(context, this, sites(context).op_quo, other); }
/** flo_quo * */ @JRubyMethod(name = {"quo", "fdiv"}) public IRubyObject quo(ThreadContext context, IRubyObject other) { return numFuncall(context, this, sites(context).op_quo, other); }
/** flo_ge * */ @JRubyMethod(name = ">=", required = 1) public IRubyObject op_ge(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value >= b); default: return coerceRelOp(context, sites(context).op_ge, other); } }
/** flo_gt * */ @JRubyMethod(name = ">", required = 1) public IRubyObject op_gt(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value > b); default: return coerceRelOp(context, sites(context).op_gt, other); } }
/** flo_lt * */ @JRubyMethod(name = "<", required = 1) public IRubyObject op_lt(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value < b); default: return coerceRelOp(context, sites(context).op_lt, other); } }
/** flo_le * */ @JRubyMethod(name = "<=", required = 1) public IRubyObject op_le(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value <= b); default: return coerceRelOp(context, sites(context).op_le, other); } }
/** flo_gt * */ @JRubyMethod(name = ">", required = 1) public IRubyObject op_gt(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value > b); default: return coerceRelOp(context, sites(context).op_gt, other); } }
/** flo_lt * */ @JRubyMethod(name = "<", required = 1) public IRubyObject op_lt(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value < b); default: return coerceRelOp(context, sites(context).op_lt, other); } }
/** flo_ge * */ @JRubyMethod(name = ">=", required = 1) public IRubyObject op_ge(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value >= b); default: return coerceRelOp(context, sites(context).op_ge, other); } }
/** flo_le * */ @JRubyMethod(name = "<=", required = 1) public IRubyObject op_le(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double b = ((RubyNumeric) other).getDoubleValue(); return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value <= b); default: return coerceRelOp(context, sites(context).op_le, other); } }
@Override public final int compareTo(IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return Double.compare(value, ((RubyNumeric) other).getDoubleValue()); default: ThreadContext context = getRuntime().getCurrentContext(); return (int) coerceCmp(context, sites(context).op_cmp, other).convertToInteger().getLongValue(); } }
@Override public final int compareTo(IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return Double.compare(value, ((RubyNumeric) other).getDoubleValue()); default: ThreadContext context = getRuntime().getCurrentContext(); return (int) coerceCmp(context, sites(context).op_cmp, other).convertToInteger().getLongValue(); } }
/** flo_mul * */ @JRubyMethod(name = "*", required = 1) public IRubyObject op_mul(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return RubyFloat.newFloat(context.runtime, value * ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, sites(context).op_times, other); } }
/** flo_minus * */ @JRubyMethod(name = "-", required = 1) public IRubyObject op_minus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return RubyFloat.newFloat(context.runtime, value - ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, sites(context).op_minus, other); } }
/** flo_minus * */ @JRubyMethod(name = "-", required = 1) public IRubyObject op_minus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return RubyFloat.newFloat(context.runtime, value - ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, sites(context).op_minus, other); } }
/** flo_mul * */ @JRubyMethod(name = "*", required = 1) public IRubyObject op_mul(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return RubyFloat.newFloat(context.runtime, value * ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, sites(context).op_times, other); } }
/** flo_plus * */ @JRubyMethod(name = "+", required = 1) @Override public IRubyObject op_plus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return RubyFloat.newFloat(context.runtime, value + ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, sites(context).op_plus, other); } }
/** flo_plus * */ @JRubyMethod(name = "+", required = 1) @Override public IRubyObject op_plus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: return RubyFloat.newFloat(context.runtime, value + ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, sites(context).op_plus, other); } }
/** flo_mod * */ @JRubyMethod(name = {"%", "modulo"}, required = 1) public IRubyObject op_mod(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double y = ((RubyNumeric) other).getDoubleValue(); if (y == 0) throw context.runtime.newZeroDivisionError(); return op_mod(context, y); default: return coerceBin(context, sites(context).op_mod, other); } }
/** flo_mod * */ @JRubyMethod(name = {"%", "modulo"}, required = 1) public IRubyObject op_mod(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: double y = ((RubyNumeric) other).getDoubleValue(); if (y == 0) throw context.runtime.newZeroDivisionError(); return op_mod(context, y); default: return coerceBin(context, sites(context).op_mod, other); } }