Module: Kernel

Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#BigDecimal(initial, digits, exception: true) ⇒ Object

Create a new BigDecimal object.

initial

The initial value, as an Integer, a Float, a Rational, a BigDecimal, or a String.

If it is a String, spaces are ignored and unrecognized characters terminate the value.

digits

The number of significant digits, as an Integer. If omitted or 0, the number of significant digits is determined from the initial value.

The actual number of significant digits used in computation is usually larger than the specified number.

exception

Whether an exception should be raised on invalid arguments. true by default, if passed false, just returns nil for invalid.

Exceptions

TypeError

If the initial type is neither Integer, Float, Rational, nor BigDecimal, this exception is raised.

TypeError

If the digits is not an Integer, this exception is raised.

ArgumentError

If initial is a Float, and the digits is larger than Float::DIG + 1, this exception is raised.

ArgumentError

If the initial is a Float or Rational, and the digits value is omitted, this exception is raised.



2723
2724
2725
2726
2727
# File 'ext/bigdecimal/bigdecimal.c', line 2723

static VALUE
f_BigDecimal(int argc, VALUE *argv, VALUE self)
{
    return BigDecimal_new(argc, argv, rb_cBigDecimal);
}