@Override public long getLongValue() { return big2long(this); }
@Override public int getIntValue() { return (int)big2long(this); }
@Override public long getLongValue() { return big2long(this); }
@Override public int getIntValue() { return (int)big2long(this); }
@Override public long getLongValue() { return big2long(this); }
@Override public long getLongValue() { return big2long(this); }
private boolean is_even(IRubyObject x) { if (x instanceof RubyFixnum) { return RubyNumeric.fix2long((RubyFixnum) x) % 2 == 0; } if (x instanceof RubyBignum) { return RubyBignum.big2long((RubyBignum) x) % 2 == 0; } return false; } }// RubyBigdecimal
private boolean is_even(IRubyObject x) { if (x instanceof RubyFixnum) { return RubyNumeric.fix2long((RubyFixnum) x) % 2 == 0; } if (x instanceof RubyBignum) { return RubyBignum.big2long((RubyBignum) x) % 2 == 0; } return false; } }// RubyBigdecimal
/** rb_big_rshift * */ @Override public IRubyObject op_rshift(ThreadContext context, IRubyObject other) { long shift; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum) other).getLongValue(); break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum) other; if (otherBignum.value.signum() >= 0) { IRubyObject tmp = otherBignum.checkShiftDown(context, this); if (tmp != null) return tmp; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return op_rshift(context, shift); }
/** rb_big_lshift * */ @Override public IRubyObject op_lshift(ThreadContext context, IRubyObject other) { long shift; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum) other).getLongValue(); break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum) other; if (otherBignum.value.signum() < 0) { IRubyObject tmp = otherBignum.checkShiftDown(context, this); if (tmp != null) return tmp; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return op_lshift(context, shift); }
/** rb_big_lshift * */ @Override public IRubyObject op_lshift(ThreadContext context, IRubyObject other) { long shift; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum) other).getLongValue(); break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum) other; if (otherBignum.value.signum() < 0) { IRubyObject tmp = otherBignum.checkShiftDown(context, this); if (tmp != null) return tmp; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return op_lshift(context, shift); }
/** rb_big_rshift * */ @Override public IRubyObject op_rshift(ThreadContext context, IRubyObject other) { long shift; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum) other).getLongValue(); break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum) other; if (otherBignum.value.signum() >= 0) { IRubyObject tmp = otherBignum.checkShiftDown(context, this); if (tmp != null) return tmp; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return op_rshift(context, shift); }
/** rb_big_lshift * */ @JRubyMethod(name = "<<", required = 1) public IRubyObject op_lshift(IRubyObject other) { long shift; boolean neg = false; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum)other).getLongValue(); if (shift < 0) { neg = true; shift = -shift; } break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum)other; if (otherBignum.value.signum() < 0) { IRubyObject tmp = otherBignum.checkShiftDown(this); if (!tmp.isNil()) return tmp; neg = true; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return bignorm(getRuntime(), neg ? value.shiftRight((int)shift) : value.shiftLeft((int)shift)); }
/** rb_big_lshift * */ @JRubyMethod(name = "<<", required = 1) public IRubyObject op_lshift(IRubyObject other) { long shift; boolean neg = false; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum)other).getLongValue(); if (shift < 0) { neg = true; shift = -shift; } break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum)other; if (otherBignum.value.signum() < 0) { IRubyObject tmp = otherBignum.checkShiftDown(this); if (!tmp.isNil()) return tmp; neg = true; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return bignorm(getRuntime(), neg ? value.shiftRight((int)shift) : value.shiftLeft((int)shift)); }
/** rb_big_rshift * */ @JRubyMethod(name = ">>", required = 1) public IRubyObject op_rshift(IRubyObject other) { long shift; boolean neg = false; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum)other).getLongValue(); if (shift < 0) { neg = true; shift = -shift; } break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum)other; if (otherBignum.value.signum() >= 0) { IRubyObject tmp = otherBignum.checkShiftDown(this); if (!tmp.isNil()) return tmp; } else { neg = true; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return bignorm(getRuntime(), neg ? value.shiftLeft((int)shift) : value.shiftRight((int)shift)); }
/** rb_big_rshift * */ @JRubyMethod(name = ">>", required = 1) public IRubyObject op_rshift(IRubyObject other) { long shift; boolean neg = false; for (;;) { if (other instanceof RubyFixnum) { shift = ((RubyFixnum)other).getLongValue(); if (shift < 0) { neg = true; shift = -shift; } break; } else if (other instanceof RubyBignum) { RubyBignum otherBignum = (RubyBignum)other; if (otherBignum.value.signum() >= 0) { IRubyObject tmp = otherBignum.checkShiftDown(this); if (!tmp.isNil()) return tmp; } else { neg = true; } shift = big2long(otherBignum); break; } other = other.convertToInteger(); } return bignorm(getRuntime(), neg ? value.shiftLeft((int)shift) : value.shiftRight((int)shift)); }
private static long other2long(IRubyObject arg) throws RaiseException { if (arg instanceof RubyFloat) return float2long((RubyFloat) arg); if (arg instanceof RubyBignum) return RubyBignum.big2long((RubyBignum) arg); if (arg.isNil()) { throw arg.getRuntime().newTypeError("no implicit conversion from nil to integer"); } return arg.convertToInteger().getLongValue(); }
private static long other2long(IRubyObject arg) throws RaiseException { if (arg.isNil()) { throw arg.getRuntime().newTypeError("no implicit conversion from nil to integer"); } else if (arg instanceof RubyFloat) { return float2long((RubyFloat)arg); } else if (arg instanceof RubyBignum) { return RubyBignum.big2long((RubyBignum) arg); } return arg.convertToInteger().getLongValue(); }
private static long other2long(IRubyObject arg) throws RaiseException { if (arg instanceof RubyFloat) return float2long((RubyFloat) arg); if (arg instanceof RubyBignum) return RubyBignum.big2long((RubyBignum) arg); if (arg.isNil()) { throw arg.getRuntime().newTypeError("no implicit conversion from nil to integer"); } return arg.convertToInteger().getLongValue(); }
private static long other2long(IRubyObject arg) throws RaiseException { if (arg.isNil()) { throw arg.getRuntime().newTypeError("no implicit conversion from nil to integer"); } else if (arg instanceof RubyFloat) { return float2long((RubyFloat)arg); } else if (arg instanceof RubyBignum) { return RubyBignum.big2long((RubyBignum) arg); } return arg.convertToInteger().getLongValue(); }