本文整理了Java中org.jruby.Ruby.newFloatDomainError
方法的一些代码示例,展示了Ruby.newFloatDomainError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newFloatDomainError
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newFloatDomainError
暂无
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/** rb_dbl2big + LONG2FIX at once (numeric.c)
*
*/
public static IRubyObject dbl2num(Ruby runtime, double val) {
if (Double.isInfinite(val)) {
throw runtime.newFloatDomainError(val < 0 ? "-Infinity" : "Infinity");
}
if (Double.isNaN(val)) {
throw runtime.newFloatDomainError("NaN");
}
return convertToNum(val, runtime);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_dbl2big + LONG2FIX at once (numeric.c)
*
*/
public static IRubyObject dbl2num(Ruby runtime, double val) {
if (Double.isInfinite(val)) {
throw runtime.newFloatDomainError(val < 0 ? "-Infinity" : "Infinity");
}
if (Double.isNaN(val)) {
throw runtime.newFloatDomainError("NaN");
}
return convertToNum(val, runtime);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private void checkFloatDomain() {
if (isNaN) {
throw this.getRuntime().newFloatDomainError("NaN");
}
if (infinitySign != 0) {
if (infinitySign == -1) {
throw getRuntime().newFloatDomainError("-Infinity");
} else {
throw getRuntime().newFloatDomainError("Infinity");
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private void checkFloatDomain() {
if (isNaN) {
throw this.getRuntime().newFloatDomainError("NaN");
}
if (infinitySign != 0) {
if (infinitySign == -1) {
throw getRuntime().newFloatDomainError("-Infinity");
} else {
throw getRuntime().newFloatDomainError("Infinity");
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Return a Bignum for the given value, or raise FloatDomainError if it is out of range.
*
* Note this method may return Bignum that are in Fixnum range.
*/
public static RubyBignum newBignum(Ruby runtime, double value) {
try {
return newBignum(runtime, toBigInteger(value));
} catch (NumberFormatException nfe) {
throw runtime.newFloatDomainError(Double.toString(value));
}
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Return a Bignum or Fixnum (Integer) for the given value, or raise FloatDomainError if it is out of range.
*
* MRI: rb_dbl2big
*/
public static RubyInteger newBignorm(Ruby runtime, double value) {
try {
return bignorm(runtime, toBigInteger(value));
} catch (NumberFormatException nfe) {
throw runtime.newFloatDomainError(Double.toString(value));
}
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Return a Bignum or Fixnum (Integer) for the given value, or raise FloatDomainError if it is out of range.
*
* MRI: rb_dbl2big
*/
public static RubyInteger newBignorm(Ruby runtime, double value) {
try {
return bignorm(runtime, toBigInteger(value));
} catch (NumberFormatException nfe) {
throw runtime.newFloatDomainError(Double.toString(value));
}
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Return a Bignum for the given value, or raise FloatDomainError if it is out of range.
*
* Note this method may return Bignum that are in Fixnum range.
*/
public static RubyBignum newBignum(Ruby runtime, double value) {
try {
return newBignum(runtime, toBigInteger(value));
} catch (NumberFormatException nfe) {
throw runtime.newFloatDomainError(Double.toString(value));
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static boolean fixable(Ruby runtime, double f) {
if (Double.isNaN(f) || Double.isInfinite(f)) {
throw runtime.newFloatDomainError(Double.toString(f));
}
long l = (long) f;
if (l == RubyFixnum.MIN || l == RubyFixnum.MAX) {
BigInteger bigint = BigDecimal.valueOf(f).toBigInteger();
return posFixable(bigint) && negFixable(bigint);
}
return posFixable(f) && negFixable(f);
}
代码示例来源:origin: org.jruby/jruby-core
public static boolean fixable(Ruby runtime, double f) {
if (Double.isNaN(f) || Double.isInfinite(f)) {
throw runtime.newFloatDomainError(Double.toString(f));
}
long l = (long) f;
if (l == RubyFixnum.MIN || l == RubyFixnum.MAX) {
BigInteger bigint = BigDecimal.valueOf(f).toBigInteger();
return posFixable(bigint) && negFixable(bigint);
}
return posFixable(f) && negFixable(f);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static RubyBigDecimal newInfinity(Ruby runtime, int sign) {
int infinitySign;
if (sign < 0) {
infinitySign = -1;
} else {
infinitySign = 1;
}
RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO, infinitySign);
if (isInfinityExceptionMode(runtime)) throw runtime.newFloatDomainError("Computation results to 'Infinity'");
return rbd;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static RubyBigDecimal newNaN(Ruby runtime) {
if (isNaNExceptionMode(runtime)) throw runtime.newFloatDomainError("Computation results to 'NaN'(Not a Number)");
RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO, true);
return rbd;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static RubyBigDecimal newInfinity(Ruby runtime, int sign) {
int infinitySign;
if (sign < 0) {
infinitySign = -1;
} else {
infinitySign = 1;
}
RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO, infinitySign);
if (isInfinityExceptionMode(runtime)) throw runtime.newFloatDomainError("Computation results to 'Infinity'");
return rbd;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static RubyBigDecimal newNaN(Ruby runtime) {
if (isNaNExceptionMode(runtime)) throw runtime.newFloatDomainError("Computation results to 'NaN'(Not a Number)");
RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO, true);
return rbd;
}
代码示例来源:origin: org.jruby/jruby-complete
private void checkFloatDomain() {
if (isNaN()) throw this.getRuntime().newFloatDomainError("NaN");
if (isInfinity()) throw getRuntime().newFloatDomainError(infinityString(infinitySign));
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod
public IRubyObject sqrt(IRubyObject arg) {
Ruby runtime = getRuntime();
if (isNaN()) throw runtime.newFloatDomainError("sqrt of NaN");
if ((isInfinity() && infinitySign < 0) || value.signum() < 0) throw runtime.newFloatDomainError("sqrt of negative value");
if (isInfinity() && infinitySign > 0) return newInfinity(runtime, 1);
// NOTE: MRI's sqrt precision is limited by 100, but we allow values more than 100.
int n = getPrecisionInt(runtime, arg) + VP_DOUBLE_FIG + BASE_FIG;
//int mx = value.precision() * (BASE_FIG + 1);
//if (mx <= n) mx = n;
return new RubyBigDecimal(runtime, bigSqrt(value, new MathContext(n, RoundingMode.HALF_UP))).setResult();
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod
public IRubyObject sqrt(IRubyObject arg) {
Ruby runtime = getRuntime();
if (isNaN()) throw runtime.newFloatDomainError("sqrt of NaN");
if ((isInfinity() && infinitySign < 0) || value.signum() < 0) throw runtime.newFloatDomainError("sqrt of negative value");
if (isInfinity() && infinitySign > 0) return newInfinity(runtime, 1);
// NOTE: MRI's sqrt precision is limited by 100, but we allow values more than 100.
int n = getPrecisionInt(runtime, arg) + VP_DOUBLE_FIG + BASE_FIG;
//int mx = value.precision() * (BASE_FIG + 1);
//if (mx <= n) mx = n;
return new RubyBigDecimal(runtime, bigSqrt(value, new MathContext(n, RoundingMode.HALF_UP))).setResult();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "div", compat = CompatVersion.RUBY1_9)
public IRubyObject op_div19(ThreadContext context, IRubyObject other, IRubyObject digits) {
RubyBigDecimal val = getVpValue(other, false);
if (isNaN() || val.isNaN()) {
throw context.runtime.newFloatDomainError("Computation results to 'NaN'");
}
return op_div(context, other, digits);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "floor", optional =1, compat = CompatVersion.RUBY1_9)
public IRubyObject floor19(IRubyObject[] args) {
if (isNaN || isInfinity()) {
throw getRuntime().newFloatDomainError("Computation results to '" + to_s(args).asJavaString() + "'");
}
return floor(args);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "floor", optional =1, compat = CompatVersion.RUBY1_9)
public IRubyObject floor19(IRubyObject[] args) {
if (isNaN || isInfinity()) {
throw getRuntime().newFloatDomainError("Computation results to '" + to_s(args).asJavaString() + "'");
}
return floor(args);
}
内容来源于网络,如有侵权,请联系作者删除!