module Kernel
Public Instance Methods
Create a new BigDecimal
object.
- initial
-
The initial value, as an
Integer
, aFloat
, aRational
, aBigDecimal
, or aString
.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 passedfalse
, just returnsnil
for invalid.
Exceptions¶ ↑
- TypeError
-
If the
initial
type is neitherInteger
,Float
,Rational
, norBigDecimal
, this exception is raised. - TypeError
-
If the
digits
is not anInteger
, this exception is raised. - ArgumentError
-
If
initial
is aFloat
, and thedigits
is larger than Float::DIG + 1, this exception is raised. - ArgumentError
-
If the
initial
is aFloat
orRational
, and thedigits
value is omitted, this exception is raised.
static VALUE f_BigDecimal(int argc, VALUE *argv, VALUE self) { return BigDecimal_new(argc, argv, rb_cBigDecimal); }