/** flo_pow * */ @JRubyMethod(name = "**", required = 1) public IRubyObject op_pow(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), Math.pow(value, ((RubyNumeric) other) .getDoubleValue())); default: return coerceBin(context, "**", other); } }
/** flo_pow * */ @JRubyMethod(name = "**", required = 1) public IRubyObject op_pow(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), Math.pow(value, ((RubyNumeric) other) .getDoubleValue())); default: return coerceBin(context, "**", other); } }
/** flo_mod * */ @JRubyMethod(name = {"%", "modulo"}, required = 1, compat = CompatVersion.RUBY1_8) public IRubyObject op_mod(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: double y = ((RubyNumeric) other).getDoubleValue(); return op_mod(context, y); default: return coerceBin(context, "%", other); } }
/** flo_mod * */ @JRubyMethod(name = {"%", "modulo"}, required = 1, compat = CompatVersion.RUBY1_8) public IRubyObject op_mod(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: double y = ((RubyNumeric) other).getDoubleValue(); return op_mod(context, y); default: return coerceBin(context, "%", other); } }
/** flo_minus * */ @JRubyMethod(name = "-", required = 1) public IRubyObject op_minus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), value - ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "-", other); } }
/** flo_minus * */ @JRubyMethod(name = "-", required = 1) public IRubyObject op_minus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), value - ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "-", other); } }
/** flo_div * */ @JRubyMethod(name = "/", required = 1) public IRubyObject op_fdiv(ThreadContext context, IRubyObject other) { // don't override Numeric#div ! switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), value / ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "/", other); } }
/** flo_div * */ @JRubyMethod(name = "/", required = 1) public IRubyObject op_fdiv(ThreadContext context, IRubyObject other) { // don't override Numeric#div ! switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), value / ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "/", other); } }
/** flo_mul * */ @JRubyMethod(name = "*", required = 1) public IRubyObject op_mul(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat( getRuntime(), value * ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "*", other); } }
/** flo_plus * */ @JRubyMethod(name = "+", required = 1) public IRubyObject op_plus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), value + ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "+", other); } }
/** flo_plus * */ @JRubyMethod(name = "+", required = 1) public IRubyObject op_plus(ThreadContext context, IRubyObject other) { switch (other.getMetaClass().index) { case ClassIndex.FIXNUM: case ClassIndex.BIGNUM: case ClassIndex.FLOAT: return RubyFloat.newFloat(getRuntime(), value + ((RubyNumeric) other).getDoubleValue()); default: return coerceBin(context, "+", other); } }
/** * MRI: flo_div */ @JRubyMethod(name = "/", required = 1) public IRubyObject op_div(ThreadContext context, IRubyObject other) { // don't override Numeric#div ! switch (other.getMetaClass().getClassIndex()) { case INTEGER: case FLOAT: try { return RubyFloat.newFloat(context.runtime, value / ((RubyNumeric) other).getDoubleValue()); } catch (NumberFormatException nfe) { throw context.runtime.newFloatDomainError(other.toString()); } default: return coerceBin(context, sites(context).op_quo, 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_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); } }