From 544d29ee25f4cf8adabed2b616e6988266b085e3 Mon Sep 17 00:00:00 2001
From: Michael Mclaughlin
is a numeric value in the specified
base
, or base 10
if
base
is omitted or is null
or undefined
.
+ Note that the BigNnumber constructor accepts an n
of type number purely
+ as a convenience so that string quotes don't have to be typed when entering literal values,
+ and that it is the toString
value of n
that is used rather than its
+ underlying binary floating point value converted to decimal.
+
x = new BigNumber(123.4567) // '123.4567' // 'new' is optional y = BigNumber(x) // '123.4567'
- If n
is a base 10
value it can be in normal (fixed-point) or
- exponential notation. Values in other bases must be in normal notation. Values in any base can
- have fraction digits, i.e. digits after the decimal point.
+ If n
is a base 10
value it can be in normal or exponential notation.
+ Values in other bases must be in normal notation. Values in any base can have fraction digits,
+ i.e. digits after the decimal point.
new BigNumber(43210) // '43210' @@ -257,7 +263,7 @@
To aid in debugging, if
@@ -325,9 +331,9 @@BigNumber.DEBUG
istrue
then an error will be thrown on an invalidn
. An error will also be thrown ifn
is of - type number with more than15
significant digits, as calling + type number and has more than15
significant digits, as callingtoString
orvalueOf
on these numbers may not result in the intended value.config
set([object]) ⇒ object20
- The maximum number of decimal places of the results of operations involving - division, i.e. division, square root and base conversion operations, and power - operations with negative exponents.
+ The maximum number of decimal places of the results of operations involving + division, i.e. division, square root and base conversion operations, and power operations + with negative exponents.
BigNumber.config({ DECIMAL_PLACES: 5 }) @@ -1331,7 +1337,7 @@isZero
.isZero() ⇒ boolean
x = new BigNumber(-0) -x.isZero() && x.isNegative() // true +x.isZero() && x.isNegative() // true y = new BigNumber(Infinity) y.isZero() // falseNote:
@@ -1454,7 +1460,7 @@n == 0
can be used ifn >= Number.MIN_VALUE
.
If
+ if the value of this BigNumber is ±d
is omitted or isnull
orundefined
, the return value is the number of significant digits of the value of this BigNumber, ornull
- if the value of this BigNumber is ±Infinity
orNaN
.Infinity
orNaN
.If
d
istrue
then any trailing zeros of the integer @@ -2158,7 +2164,7 @@Errors
try { // ... } catch (e) { - if (e instanceof Error && e.message.indexOf('[BigNumber Error]') === 0) { + if (e instanceof Error && e.message.indexOf('[BigNumber Error]') === 0) { // ... } }