Tabnine Logo
RubyBignum.getDoubleValue
Code IndexAdd Tabnine to your IDE (free)

How to use
getDoubleValue
method
in
org.jruby.RubyBignum

Best Java code snippets using org.jruby.RubyBignum.getDoubleValue (Showing top 20 results out of 315)

origin: org.jruby/jruby-complete

/** rb_big_to_f
 *
 */
@Override
public IRubyObject to_f(ThreadContext context) {
  return RubyFloat.newFloat(context.runtime, getDoubleValue());
}
origin: org.jruby/jruby-core

/** rb_big_to_f
 *
 */
@Override
public IRubyObject to_f(ThreadContext context) {
  return RubyFloat.newFloat(context.runtime, getDoubleValue());
}
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

@Override
public IRubyObject to_f() {
  return RubyFloat.newFloat(getRuntime(), getDoubleValue());
}
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

@Override
public IRubyObject to_f() {
  return RubyFloat.newFloat(getRuntime(), getDoubleValue());
}
origin: com.ning.billing/killbill-osgi-bundles-jruby

/** rb_big_to_f
 *
 */
@JRubyMethod(name = "to_f")
public IRubyObject to_f() {
  return RubyFloat.newFloat(getRuntime(), getDoubleValue());
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** rb_big_to_f
 *
 */
@JRubyMethod(name = "to_f")
public IRubyObject to_f() {
  return RubyFloat.newFloat(getRuntime(), getDoubleValue());
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** fix_quo
 * 
 */
@JRubyMethod(name = "quo", compat = RUBY1_8)
@Override
public IRubyObject quo(ThreadContext context, IRubyObject other) {
  if (other instanceof RubyFixnum) {
    return RubyFloat.newFloat(context.runtime, (double) value / (double) ((RubyFixnum) other).value);
  } else if (other instanceof RubyBignum) {
    return RubyFloat.newFloat(context.runtime, (double) value / (double) ((RubyBignum) other).getDoubleValue());
  }
  return coerceBin(context, "quo", other);
}
origin: com.ning.billing/killbill-osgi-bundles-jruby

/** fix_quo
 * 
 */
@JRubyMethod(name = "quo", compat = RUBY1_8)
@Override
public IRubyObject quo(ThreadContext context, IRubyObject other) {
  if (other instanceof RubyFixnum) {
    return RubyFloat.newFloat(context.runtime, (double) value / (double) ((RubyFixnum) other).value);
  } else if (other instanceof RubyBignum) {
    return RubyFloat.newFloat(context.runtime, (double) value / (double) ((RubyBignum) other).getDoubleValue());
  }
  return coerceBin(context, "quo", other);
}
origin: org.jruby/jruby-complete

@Override
public IRubyObject fdivDouble(ThreadContext context, IRubyObject y) {
  double dx, dy;
  dx = getDoubleValue();
  if (y instanceof RubyFixnum) {
    long ly = ((RubyFixnum) y).getLongValue();
    if (Double.isInfinite(dx)) {
      return fdivInt(context.runtime, BigDecimal.valueOf(ly));
    }
    dy = (double) ly;
  } else if (y instanceof RubyBignum) {
    return fdivDouble(context, (RubyBignum) y);
  } else if (y instanceof RubyFloat) {
    dy = ((RubyFloat) y).getDoubleValue();
    if (Double.isNaN(dy)) {
      return context.runtime.newFloat(dy);
    }
    if (Double.isInfinite(dx)) {
      return fdivFloat(context, (RubyFloat) y);
    }
  } else {
    return coerceBin(context, sites(context).fdiv, y);
  }
  return context.runtime.newFloat(dx / dy);
}
origin: org.jruby/jruby-core

@Override
public IRubyObject fdivDouble(ThreadContext context, IRubyObject y) {
  double dx, dy;
  dx = getDoubleValue();
  if (y instanceof RubyFixnum) {
    long ly = ((RubyFixnum) y).getLongValue();
    if (Double.isInfinite(dx)) {
      return fdivInt(context.runtime, BigDecimal.valueOf(ly));
    }
    dy = (double) ly;
  } else if (y instanceof RubyBignum) {
    return fdivDouble(context, (RubyBignum) y);
  } else if (y instanceof RubyFloat) {
    dy = ((RubyFloat) y).getDoubleValue();
    if (Double.isNaN(dy)) {
      return context.runtime.newFloat(dy);
    }
    if (Double.isInfinite(dx)) {
      return fdivFloat(context, (RubyFloat) y);
    }
  } else {
    return coerceBin(context, sites(context).fdiv, y);
  }
  return context.runtime.newFloat(dx / dy);
}
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** rb_big_pow
 *
 */
@JRubyMethod(name = {"**", "power"}, required = 1)
public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
  double d;
  if (other instanceof RubyFixnum) {
    RubyFixnum fix = (RubyFixnum) other;
    long fixValue = fix.getLongValue();
    return op_pow(context, fixValue);
  } else if (other instanceof RubyBignum) {
    d = ((RubyBignum) other).getDoubleValue();
    getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
  } else if (other instanceof RubyFloat) {
    d = ((RubyFloat) other).getDoubleValue();
  } else {
    return coerceBin(context, "**", other);
  }
  return RubyFloat.newFloat(getRuntime(), Math.pow(big2dbl(this), d));
}
origin: com.ning.billing/killbill-osgi-bundles-jruby

/** rb_big_pow
 *
 */
@JRubyMethod(name = {"**", "power"}, required = 1)
public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
  double d;
  if (other instanceof RubyFixnum) {
    RubyFixnum fix = (RubyFixnum) other;
    long fixValue = fix.getLongValue();
    return op_pow(context, fixValue);
  } else if (other instanceof RubyBignum) {
    d = ((RubyBignum) other).getDoubleValue();
    getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
  } else if (other instanceof RubyFloat) {
    d = ((RubyFloat) other).getDoubleValue();
  } else {
    return coerceBin(context, "**", other);
  }
  return RubyFloat.newFloat(getRuntime(), Math.pow(big2dbl(this), d));
}
origin: com.ning.billing/killbill-osgi-bundles-jruby

  d = ((RubyBignum) other).getDoubleValue();
  getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
} else if (other instanceof RubyFloat) {
origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  d = ((RubyBignum) other).getDoubleValue();
  getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
} else if (other instanceof RubyFloat) {
origin: org.jruby/jruby-complete

/** rb_big_pow
 *
 */
@Override
@JRubyMethod(name = {"**", "power"}, required = 1)
public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
  Ruby runtime = context.runtime;
  if (other == RubyFixnum.zero(runtime)) return RubyFixnum.one(runtime);
  final double d;
  if (other instanceof RubyFloat) {
    d = ((RubyFloat) other).getDoubleValue();
    if (compareTo(RubyFixnum.zero(runtime)) == -1 && d != Math.round(d)) {
      RubyComplex complex = RubyComplex.newComplexRaw(context.runtime, this);
      return sites(context).op_exp.call(context, complex, complex, other);
    }
  } else if (other instanceof RubyBignum) {
    d = ((RubyBignum) other).getDoubleValue();
    context.runtime.getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
  } else if (other instanceof RubyFixnum) {
    return op_pow(context, other.convertToInteger().getLongValue());
  } else {
    return coerceBin(context, sites(context).op_exp, other);
  }
  return pow(runtime, d);
}
origin: org.jruby/jruby-core

/** rb_big_pow
 *
 */
@Override
@JRubyMethod(name = {"**", "power"}, required = 1)
public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
  Ruby runtime = context.runtime;
  if (other == RubyFixnum.zero(runtime)) return RubyFixnum.one(runtime);
  final double d;
  if (other instanceof RubyFloat) {
    d = ((RubyFloat) other).getDoubleValue();
    if (compareTo(RubyFixnum.zero(runtime)) == -1 && d != Math.round(d)) {
      RubyComplex complex = RubyComplex.newComplexRaw(context.runtime, this);
      return sites(context).op_exp.call(context, complex, complex, other);
    }
  } else if (other instanceof RubyBignum) {
    d = ((RubyBignum) other).getDoubleValue();
    context.runtime.getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big");
  } else if (other instanceof RubyFixnum) {
    return op_pow(context, other.convertToInteger().getLongValue());
  } else {
    return coerceBin(context, sites(context).op_exp, other);
  }
  return pow(runtime, d);
}
origin: org.jruby/jruby-complete

/** rb_num2dbl and NUM2DBL
 *
 */
public static double num2dbl(ThreadContext context, IRubyObject arg) {
  switch (((RubyBasicObject) arg).getNativeClassIndex()) {
    case FLOAT:
      return ((RubyFloat) arg).getDoubleValue();
    case FIXNUM:
      if (context.sites.Fixnum.to_f.isBuiltin(getMetaClass(arg))) return ((RubyFixnum) arg).getDoubleValue();
      break;
    case BIGNUM:
      if (context.sites.Bignum.to_f.isBuiltin(getMetaClass(arg))) return ((RubyBignum) arg).getDoubleValue();
      break;
    case RATIONAL:
      if (context.sites.Rational.to_f.isBuiltin(getMetaClass(arg))) return ((RubyRational) arg).getDoubleValue();
      break;
    case STRING:
    case NIL:
    case TRUE:
    case FALSE:
      throw context.runtime.newTypeError(str(context.runtime, "can't convert ", arg.inspect(), " into Float"));
  }
  IRubyObject val = TypeConverter.convertToType(arg, context.runtime.getFloat(), "to_f");
  return ((RubyFloat) val).getDoubleValue();
}
origin: org.jruby/jruby-core

/** rb_num2dbl and NUM2DBL
 *
 */
public static double num2dbl(ThreadContext context, IRubyObject arg) {
  switch (((RubyBasicObject) arg).getNativeClassIndex()) {
    case FLOAT:
      return ((RubyFloat) arg).getDoubleValue();
    case FIXNUM:
      if (context.sites.Fixnum.to_f.isBuiltin(getMetaClass(arg))) return ((RubyFixnum) arg).getDoubleValue();
      break;
    case BIGNUM:
      if (context.sites.Bignum.to_f.isBuiltin(getMetaClass(arg))) return ((RubyBignum) arg).getDoubleValue();
      break;
    case RATIONAL:
      if (context.sites.Rational.to_f.isBuiltin(getMetaClass(arg))) return ((RubyRational) arg).getDoubleValue();
      break;
    case STRING:
    case NIL:
    case TRUE:
    case FALSE:
      throw context.runtime.newTypeError(str(context.runtime, "can't convert ", arg.inspect(), " into Float"));
  }
  IRubyObject val = TypeConverter.convertToType(arg, context.runtime.getFloat(), "to_f");
  return ((RubyFloat) val).getDoubleValue();
}
org.jrubyRubyBignumgetDoubleValue

Popular methods of RubyBignum

  • newBignum
  • getLongValue
  • getValue
    Getter for property value.
  • <init>
  • addFloat
  • addOther
  • big2dbl
    rb_big2dbl
  • big2long
    rb_big2long
  • bignorm
    rb_big_norm
  • checkShiftDown
  • coerceBin
  • coerceCmp
  • coerceBin,
  • coerceCmp,
  • compareTo,
  • convertToDouble,
  • createBignumClass,
  • dbl_cmp,
  • divmod,
  • even_p,
  • fix2big,
  • getBigIntegerValue

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • getContentResolver (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now