/** * MRI: macro DBL2IVAL */ public static RubyInteger dbl2ival(Ruby runtime, double val) { // MRI: macro FIXABLE, RB_FIXABLE (inlined + adjusted) : if (Double.isNaN(val) || Double.isInfinite(val)) { throw runtime.newFloatDomainError(Double.toString(val)); } final long fix = (long) val; if (fix == RubyFixnum.MIN || fix == RubyFixnum.MAX) { BigInteger big = BigDecimal.valueOf(val).toBigInteger(); if (posFixable(big) && negFixable(big)) { return RubyFixnum.newFixnum(runtime, fix); } } else if (posFixable(val) && negFixable(val)) { return RubyFixnum.newFixnum(runtime, fix); } return RubyBignum.newBignorm(runtime, val); }
/** * MRI: macro DBL2IVAL */ public static RubyInteger dbl2ival(Ruby runtime, double val) { // MRI: macro FIXABLE, RB_FIXABLE (inlined + adjusted) : if (Double.isNaN(val) || Double.isInfinite(val)) { throw runtime.newFloatDomainError(Double.toString(val)); } final long fix = (long) val; if (fix == RubyFixnum.MIN || fix == RubyFixnum.MAX) { BigInteger big = BigDecimal.valueOf(val).toBigInteger(); if (posFixable(big) && negFixable(big)) { return RubyFixnum.newFixnum(runtime, fix); } } else if (posFixable(val) && negFixable(val)) { return RubyFixnum.newFixnum(runtime, fix); } return RubyBignum.newBignorm(runtime, val); }
return runtime.newFloat(n).convertToInteger(); } else { return RubyBignum.newBignorm(runtime, n);
return runtime.newFloat(n).convertToInteger(); } else { return RubyBignum.newBignorm(runtime, n);
long n = exp[0] - DBL_MANT_DIG; RubyInteger rf = RubyBignum.newBignorm(runtime, f); RubyFixnum rn = RubyFixnum.newFixnum(runtime, n);
long n = exp[0] - DBL_MANT_DIG; RubyInteger rf = RubyBignum.newBignorm(runtime, f); RubyFixnum rn = RubyFixnum.newFixnum(runtime, n);