本文整理了Java中org.jruby.Ruby.newFloat
方法的一些代码示例,展示了Ruby.newFloat
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newFloat
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newFloat
暂无
代码示例来源:origin: bazelbuild/bazel
RubyBignum.newBignum(runtime, UINT64_COMPLEMENTARY.add(new BigInteger(ret + "")));
case FLOAT:
return runtime.newFloat((Float) value);
case DOUBLE:
return runtime.newFloat((Double) value);
case BOOL:
return (Boolean) value ? runtime.getTrue() : runtime.getFalse();
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject safe_mul(ThreadContext context, IRubyObject a, IRubyObject b, boolean az, boolean bz) {
Ruby runtime = context.runtime;
double v;
if (!az && bz && a instanceof RubyFloat && !Double.isNaN(v = ((RubyFloat)a).getDoubleValue())) {
a = v < 0.0d ? runtime.newFloat(-1.0d) : runtime.newFloat(1.0d);
}
if (!bz && az && b instanceof RubyFloat && !Double.isNaN(v = ((RubyFloat)b).getDoubleValue())) {
b = v < 0.0d ? runtime.newFloat(-1.0) : runtime.newFloat(1.0);
}
return f_mul(context, a, b);
}
代码示例来源:origin: org.jruby/jruby-core
public static IRubyObject safe_mul(ThreadContext context, IRubyObject a, IRubyObject b, boolean az, boolean bz) {
Ruby runtime = context.runtime;
double v;
if (!az && bz && a instanceof RubyFloat && !Double.isNaN(v = ((RubyFloat)a).getDoubleValue())) {
a = v < 0.0d ? runtime.newFloat(-1.0d) : runtime.newFloat(1.0d);
}
if (!bz && az && b instanceof RubyFloat && !Double.isNaN(v = ((RubyFloat)b).getDoubleValue())) {
b = v < 0.0d ? runtime.newFloat(-1.0) : runtime.newFloat(1.0);
}
return f_mul(context, a, b);
}
代码示例来源:origin: org.jruby/jruby-complete
private static IRubyObject makeClockResolutionResult(Ruby runtime, long nanos, String unit) {
if (unit.equals(CLOCK_UNIT_HERTZ)) {
return runtime.newFloat(1000000000.0 / nanos);
} else {
return makeClockResult(runtime, nanos, unit);
}
}
代码示例来源:origin: org.jruby/jruby-core
private static IRubyObject makeClockResolutionResult(Ruby runtime, long nanos, String unit) {
if (unit.equals(CLOCK_UNIT_HERTZ)) {
return runtime.newFloat(1000000000.0 / nanos);
} else {
return makeClockResult(runtime, nanos, unit);
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "to_f")
public static IRubyObject to_f(final ThreadContext context, final IRubyObject self) {
java.lang.Number val = (java.lang.Number) self.toJava(java.lang.Number.class);
return context.runtime.newFloat(val.doubleValue());
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "to_f")
public static IRubyObject to_f(final ThreadContext context, final IRubyObject self) {
java.lang.Number val = (java.lang.Number) self.toJava(java.lang.Number.class);
return context.runtime.newFloat(val.doubleValue());
}
代码示例来源:origin: org.jruby/jruby-complete
final RubyFloat fdivDouble(ThreadContext context, RubyBignum y) {
double dx = getDoubleValue();
double dy = RubyBignum.big2dbl(y);
if (Double.isInfinite(dx) || Double.isInfinite(dy)) {
return (RubyFloat) fdivInt(context, y);
}
return context.runtime.newFloat(dx / dy);
}
代码示例来源:origin: org.jruby/jruby-core
final RubyFloat fdivDouble(ThreadContext context, RubyBignum y) {
double dx = getDoubleValue();
double dy = RubyBignum.big2dbl(y);
if (Double.isInfinite(dx) || Double.isInfinite(dy)) {
return (RubyFloat) fdivInt(context, y);
}
return context.runtime.newFloat(dx / dy);
}
代码示例来源:origin: org.jruby/jruby-complete
/** nurat_to_f
*
*/
@JRubyMethod(name = "to_f")
public IRubyObject to_f(ThreadContext context) {
return context.runtime.newFloat(getDoubleValue(context));
}
代码示例来源:origin: org.jruby/jruby-core
/** nurat_to_f
*
*/
@JRubyMethod(name = "to_f")
public IRubyObject to_f(ThreadContext context) {
return context.runtime.newFloat(getDoubleValue(context));
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyFloat initFloat(MutableCallSite site, ThreadContext context, double value) {
RubyFloat rubyFloat = context.runtime.newFloat(value);
site.setTarget(dropArguments(constant(RubyFloat.class, rubyFloat), 0, ThreadContext.class));
return rubyFloat;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject addOther(ThreadContext context, IRubyObject other) {
if (other instanceof RubyBignum) {
return ((RubyBignum) other).op_plus(context, this);
}
if (other instanceof RubyFloat) {
return context.runtime.newFloat((double) value + ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, "+", other);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyFloat initFloat(MutableCallSite site, ThreadContext context, double value) {
RubyFloat rubyFloat = context.runtime.newFloat(value);
site.setTarget(dropArguments(constant(RubyFloat.class, rubyFloat), 0, ThreadContext.class));
return rubyFloat;
}
代码示例来源:origin: org.jruby/jruby-complete
private IRubyObject addOther(ThreadContext context, IRubyObject other) {
if (other instanceof RubyBignum) {
return ((RubyBignum) other).op_plus(context, this.value);
}
if (other instanceof RubyFloat) {
return context.runtime.newFloat((double) value + ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, sites(context).op_plus, other);
}
代码示例来源:origin: org.jruby/jruby-complete
private IRubyObject multiplyOther(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (other instanceof RubyBignum) {
return ((RubyBignum) other).op_mul(context, this.value);
}
if (other instanceof RubyFloat) {
return runtime.newFloat((double) value * ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, sites(context).op_times, other);
}
代码示例来源:origin: org.jruby/jruby-core
private IRubyObject multiplyOther(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (other instanceof RubyBignum) {
return ((RubyBignum) other).op_mul(context, this.value);
}
if (other instanceof RubyFloat) {
return runtime.newFloat((double) value * ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, sites(context).op_times, other);
}
代码示例来源:origin: org.jruby/jruby-core
private IRubyObject addOther(ThreadContext context, IRubyObject other) {
if (other instanceof RubyBignum) {
return ((RubyBignum) other).op_plus(context, this.value);
}
if (other instanceof RubyFloat) {
return context.runtime.newFloat((double) value + ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, sites(context).op_plus, other);
}
代码示例来源:origin: org.jruby/jruby-core
private IRubyObject subtractOther(ThreadContext context, IRubyObject other) {
if (other instanceof RubyBignum) {
return RubyBignum.newBignum(context.runtime, value).op_minus(context, ((RubyBignum) other).value);
}
if (other instanceof RubyFloat) {
return context.runtime.newFloat((double) value - ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, sites(context).op_minus, other);
}
代码示例来源:origin: org.jruby/jruby-complete
private IRubyObject subtractOther(ThreadContext context, IRubyObject other) {
if (other instanceof RubyBignum) {
return RubyBignum.newBignum(context.runtime, value).op_minus(context, ((RubyBignum) other).value);
}
if (other instanceof RubyFloat) {
return context.runtime.newFloat((double) value - ((RubyFloat) other).getDoubleValue());
}
return coerceBin(context, sites(context).op_minus, other);
}
内容来源于网络,如有侵权,请联系作者删除!