boolean isOne() { return getBigIntegerValue().equals(BigInteger.ONE); }
boolean isOne() { return getBigIntegerValue().equals(BigInteger.ONE); }
public int signum() { return getBigIntegerValue().signum(); }
public static boolean f_lt_p(ThreadContext context, RubyInteger x, RubyInteger y) { if (x instanceof RubyFixnum && y instanceof RubyFixnum) { return ((RubyFixnum)x).getLongValue() < ((RubyFixnum)y).getLongValue(); } return x.getBigIntegerValue().compareTo(y.getBigIntegerValue()) < 0; }
private static BigDecimal toBigDecimal(final RubyInteger value) { if (value instanceof RubyFixnum) { return BigDecimal.valueOf(RubyNumeric.num2long(value)); } return new BigDecimal(value.getBigIntegerValue()); }
public static boolean f_gt_p(ThreadContext context, RubyInteger x, RubyInteger y) { if (x instanceof RubyFixnum && y instanceof RubyFixnum) { return ((RubyFixnum)x).getLongValue() > ((RubyFixnum)y).getLongValue(); } return x.getBigIntegerValue().compareTo(y.getBigIntegerValue()) > 0; }
public static boolean f_lt_p(ThreadContext context, RubyInteger x, RubyInteger y) { if (x instanceof RubyFixnum && y instanceof RubyFixnum) { return ((RubyFixnum)x).getLongValue() < ((RubyFixnum)y).getLongValue(); } return x.getBigIntegerValue().compareTo(y.getBigIntegerValue()) < 0; }
@Override public BigInteger getBigIntegerValue() { return convertToInteger().getBigIntegerValue(); }
@Override public BigInteger getBigIntegerValue() { return convertToInteger().getBigIntegerValue(); }
private static BigDecimal toBigDecimal(final RubyInteger value) { if (value instanceof RubyFixnum) { return BigDecimal.valueOf(RubyNumeric.num2long(value)); } return new BigDecimal(value.getBigIntegerValue()); }
public static boolean f_gt_p(ThreadContext context, RubyInteger x, RubyInteger y) { if (x instanceof RubyFixnum && y instanceof RubyFixnum) { return ((RubyFixnum)x).getLongValue() > ((RubyFixnum)y).getLongValue(); } return x.getBigIntegerValue().compareTo(y.getBigIntegerValue()) > 0; }
public static RubyFixnum f_cmp(ThreadContext context, RubyInteger x, long y) { final int cmp; if (x instanceof RubyFixnum) { cmp = Long.compare(((RubyFixnum) x).getLongValue(), y); } else { // RubyBignum cmp = x.getBigIntegerValue().compareTo(BigInteger.valueOf(y)); } return RubyFixnum.newFixnum(context.runtime, cmp); }
public static RubyFixnum f_cmp(ThreadContext context, RubyInteger x, RubyInteger y) { final int cmp; if (x instanceof RubyFixnum && y instanceof RubyFixnum) { cmp = Long.compare(((RubyFixnum) x).getLongValue(), ((RubyFixnum) y).getLongValue()); } else { // RubyBignum || RubyFixnum cmp = x.getBigIntegerValue().compareTo(y.getBigIntegerValue()); } return RubyFixnum.newFixnum(context.runtime, cmp); }
public static RubyFixnum f_cmp(ThreadContext context, RubyInteger x, long y) { final int cmp; if (x instanceof RubyFixnum) { cmp = Long.compare(((RubyFixnum) x).getLongValue(), y); } else { // RubyBignum cmp = x.getBigIntegerValue().compareTo(BigInteger.valueOf(y)); } return RubyFixnum.newFixnum(context.runtime, cmp); }
public static RubyFixnum f_cmp(ThreadContext context, RubyInteger x, RubyInteger y) { final int cmp; if (x instanceof RubyFixnum && y instanceof RubyFixnum) { cmp = Long.compare(((RubyFixnum) x).getLongValue(), ((RubyFixnum) y).getLongValue()); } else { // RubyBignum || RubyFixnum cmp = x.getBigIntegerValue().compareTo(y.getBigIntegerValue()); } return RubyFixnum.newFixnum(context.runtime, cmp); }
protected static int nonFixnumHashCode(IRubyObject hashValue) { RubyInteger integer = hashValue.convertToInteger(); if (integer instanceof RubyBignum) { return integer.getBigIntegerValue().intValue(); } return (int) integer.getLongValue(); }
protected static int nonFixnumHashCode(IRubyObject hashValue) { RubyInteger integer = hashValue.convertToInteger(); if (integer instanceof RubyBignum) { return integer.getBigIntegerValue().intValue(); } return (int) integer.getLongValue(); }
public static RubyInteger f_gcd(ThreadContext context, RubyInteger x, RubyInteger y) { if (x instanceof RubyFixnum && y instanceof RubyFixnum && isLongMinValue((RubyFixnum) x)) return RubyFixnum.newFixnum(context.runtime, i_gcd(x.getLongValue(), y.getLongValue())); BigInteger gcd = x.getBigIntegerValue().gcd(y.getBigIntegerValue()); if (gcd.compareTo(RubyBignum.LONG_MAX) <= 0) { // gcd always positive return RubyFixnum.newFixnum(context.runtime, gcd.longValue()); } return RubyBignum.newBignum(context.runtime, gcd); }
public static RubyInteger f_gcd(ThreadContext context, RubyInteger x, RubyInteger y) { if (x instanceof RubyFixnum && y instanceof RubyFixnum && isLongMinValue((RubyFixnum) x)) return RubyFixnum.newFixnum(context.runtime, i_gcd(x.getLongValue(), y.getLongValue())); BigInteger gcd = x.getBigIntegerValue().gcd(y.getBigIntegerValue()); if (gcd.compareTo(RubyBignum.LONG_MAX) <= 0) { // gcd always positive return RubyFixnum.newFixnum(context.runtime, gcd.longValue()); } return RubyBignum.newBignum(context.runtime, gcd); }
private int nonFixnumHashCode(IRubyObject hashValue) { Ruby runtime = getRuntime(); if (runtime.is1_9()) { RubyInteger integer = hashValue.convertToInteger(); if (integer instanceof RubyBignum) { return (int)integer.getBigIntegerValue().intValue(); } else { return (int)integer.getLongValue(); } } else { hashValue = hashValue.callMethod(runtime.getCurrentContext(), "%", RubyFixnum.newFixnum(runtime, 536870923L)); if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue); return System.identityHashCode(hashValue); } }