diff --git a/index.html b/index.html index 4d0d2d8..6a3872c 100644 --- a/index.html +++ b/index.html @@ -83,6 +83,7 @@ li span{float:right;margin-right:10px;color:#c0c0c0}
this
Decimal constructor if object
is omitted.
Decimal.set({ precision: 5 }) -D9 = Decimal.clone({ precision: 9 }) +Decimal9 = Decimal.clone({ precision: 9 }) a = new Decimal(1) -b = new D9(1) +b = new Decimal9(1) a.div(3) // 0.33333 b.div(3) // 0.333333333 -// D9 = Decimal.clone({ precision: 9 }) is equivalent to: -D9 = Decimal.clone() -D9.set({ precision: 9 })+// Decimal9 = Decimal.clone({ precision: 9 }) is equivalent to: +Decimal9 = Decimal.clone() +Decimal9.set({ precision: 9 }) +
+ If object
has a 'defaults'
property with value true
+ then the new constructor will use the default configuration.
+
+D1 = Decimal.clone({ defaults: true }) + +// Use the defaults except for precision +D2 = Decimal.clone({ defaults: true, precision: 50 })
It is not inefficient in terms of memory usage to use multiple Decimal constructors as functions are shared between them.
-.cos(x) ⇒ Decimal
x
: number|string|Decimal
See cosine
.
.isDecimal(object) ⇒ boolean
+ object
: any
+ Returns true
if object
is a Decimal instance (where Decimal is any
+ Decimal constructor), or false
if it is not.
+
a = new Decimal(1) +b = {} +a instanceof Decimal // true +Decimal.isDecimal(a) // true +Decimal.isDecimal(b) // false+ + +
.log(x [, base]) ⇒ Decimal
x
: number|string|Decimal
@@ -725,6 +750,10 @@ a.equals(b) // true
The values of the configuration object properties are checked for validity and then stored as
equivalently-named properties of this
Decimal constructor.
+ If object
has a 'defaults'
property with value true
+ then any unspecified properties will be reset to their default values.
+
Throws on an invalid object
or configuration property value.
// Defaults @@ -737,7 +766,13 @@ Decimal.set({ minE: -9e15, modulo: 1, crypto: false -})+}) + +// Reset all properties to their default values +Decimal.set({ defaults: true }) + +// Set precision to 50 and all other properties to their default values +Decimal.set({ precision: 50, defaults: true })
The properties of a Decimal constructor can also be set by direct assignment, but that will by-pass the validity checking that this method performs - this is not a problem if the user @@ -2014,7 +2049,7 @@ x.toBinary(1) // '0b1p+8'
Throws on an invalid dp
or rm
value.
-x = new Decimal(12.24567) +x = new Decimal(12.34567) x.toDecimalPlaces(0) // '12' x.toDecimalPlaces(1, 0) // '12.3' @@ -2052,7 +2087,7 @@ y.toDP(1, Decimal.ROUND_DOWN) // '9876.5'
Throws on an invalid dp
or rm
value.
x = 45.6 -b = new Decimal(x) +y = new Decimal(x) x.toExponential() // '4.56e+1' y.toExponential() // '4.56e+1' x.toExponential(0) // '5e+1' @@ -2100,7 +2135,7 @@ y.toExponential(3) // '4.560e+1'
Throws on an invalid dp
or rm
value.
x = 3.456 -b = new Decimal(x) +y = new Decimal(x) x.toFixed() // '3' y.toFixed() // '3.456' y.toFixed(0) // '3' @@ -2358,7 +2393,7 @@ new Decimal(28).pow('6.166675020000903537297764507632802193308677149')Throws on an invalid
sd
orrm
value.x = 45.6 -b = new Decimal(x) +y = new Decimal(x) x.toPrecision() // '45.6' y.toPrecision() // '45.6' x.toPrecision(1) // '5e+1' @@ -2483,9 +2518,9 @@ x.valueOf() // '-0'- -1
,1
, orNaN
The properties are best considered to be read-only.
+All the properties are best considered to be read-only.
- As with JavaScript numbers, the original exponent and fractional trailing zeros of a number + As with JavaScript numbers, the original exponent and fractional trailing zeros of a value are not preserved.
@@ -2634,10 +2669,10 @@ z = x.multiply(y) // 4.1400000toPrecision
methods enable trailing zeros to be added if and when required.
- +