1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00
This commit is contained in:
Michael Mclaughlin 2016-11-09 17:08:38 +00:00
parent 46b1aad320
commit e48bddf45a
11 changed files with 171 additions and 167 deletions

View File

@ -1,6 +1,7 @@
language: node_js
node_js:
- "node"
- "7"
- "6"
- "5"
- "4"

View File

@ -1,103 +1,109 @@
####6.0.0
#### 7.0.0
* 09/11/2016
* Remove `require('crypto')` - leave it to the user
* Default `Decimal.crypto` to `false`
* Add `Decimal.set` as `Decimal.config` alias
#### 6.0.0
* 30/06/2016
* Removed base-88 serialization format.
* Amended `toJSON` and removed `Decimal.fromJSON` accordingly.
* Removed base-88 serialization format
* Amended `toJSON` and removed `Decimal.fromJSON` accordingly
####5.0.8
#### 5.0.8
* 09/03/2016
* Add newline to single test results.
* Correct year.
* Add newline to single test results
* Correct year
####5.0.7
#### 5.0.7
* 29/02/2016
* Add decimal.js-light link.
* Remove outdated example from docs.
* Add decimal.js-light link
* Remove outdated example from docs
####5.0.6
#### 5.0.6
* 22/02/2016
* Add bower.json.
* Add bower.json
####5.0.5
#### 5.0.5
* 20/02/2016
* Bugfix: #26 wrong precision applied.
* Bugfix: #26 wrong precision applied
####5.0.4
#### 5.0.4
* 14/02/2016
* Bugfix: #26 clone.
* Bugfix: #26 clone
####5.0.3
#### 5.0.3
* 06/02/2016
* Refactor tests.
* Refactor tests
####5.0.2
#### 5.0.2
* 05/02/2016
* Added immutability tests.
* Minor *decimal.js* clean-up.
* Added immutability tests
* Minor *decimal.js* clean-up
####5.0.1
#### 5.0.1
* 28/01/2016
* Bugfix: #20 cos mutates value.
* Add pi info to docs.
* Bugfix: #20 cos mutates value
* Add pi info to docs
####5.0.0
#### 5.0.0
* 25/01/2016
* Added trigonometric functions and `cubeRoot` method.
* Added most of JavaScript's `Math` object methods as Decimal methods.
* Added `toBinary`, `toHexadecimal` and `toOctal` methods.
* Added `isPositive` method.
* Removed the 15 significant digit limit for numbers.
* `toFraction` now returns an array of two Decimals, not two strings.
* String values containing whitespace or a plus sign are no longer accepted.
* `valueOf` now returns `'-0'` for minus zero.
* `comparedTo` now returns `NaN` not `null` for comparisons with `NaN`.
* `Decimal.max` and `Decimal.min` no longer accept an array.
* The Decimal constructor and `toString` no longer accept a base argument.
* Binary, hexadecimal and octal prefixes are now recognised for string values.
* Removed `Decimal.errors` configuration property.
* Removed `toFormat` method.
* Removed `Decimal.ONE`.
* Renamed `exponential` method to `naturalExponential`.
* Renamed `Decimal.constructor` method to `Decimal.clone`.
* Simplified error handling and amended error messages.
* Refactored the test suite.
* `Decimal.crypto` is now `undefined` by default, and the `crypto` object will be used if available.
* Major internal refactoring.
* Removed *bower.json*.
* Added trigonometric functions and `cubeRoot` method
* Added most of JavaScript's `Math` object methods as Decimal methods
* Added `toBinary`, `toHexadecimal` and `toOctal` methods
* Added `isPositive` method
* Removed the 15 significant digit limit for numbers
* `toFraction` now returns an array of two Decimals, not two strings
* String values containing whitespace or a plus sign are no longer accepted
* `valueOf` now returns `'-0'` for minus zero
* `comparedTo` now returns `NaN` not `null` for comparisons with `NaN`
* `Decimal.max` and `Decimal.min` no longer accept an array
* The Decimal constructor and `toString` no longer accept a base argument
* Binary, hexadecimal and octal prefixes are now recognised for string values
* Removed `Decimal.errors` configuration property
* Removed `toFormat` method
* Removed `Decimal.ONE`
* Renamed `exponential` method to `naturalExponential`
* Renamed `Decimal.constructor` method to `Decimal.clone`
* Simplified error handling and amended error messages
* Refactored the test suite
* `Decimal.crypto` is now `undefined` by default, and the `crypto` object will be used if available
* Major internal refactoring
* Removed *bower.json*
####4.0.2
* 20/02/2015 Add bower.json. Add source map. Amend travis CI. Amend doc/comments.
#### 4.0.2
* 20/02/2015 Add bower.json. Add source map. Amend travis CI. Amend doc/comments
####4.0.1
* 11/12/2014 Assign correct constructor when duplicating a Decimal.
#### 4.0.1
* 11/12/2014 Assign correct constructor when duplicating a Decimal
####4.0.0
* 10/11/2014 `toFormat` amended to use `Decimal.format` object for more flexible configuration.
#### 4.0.0
* 10/11/2014 `toFormat` amended to use `Decimal.format` object for more flexible configuration
####3.0.1
#### 3.0.1
* 8/06/2014 Surround crypto require in try catch. See issue #5
####3.0.0
#### 3.0.0
* 4/06/2014 `random` simplified. Major internal changes mean the properties of a Decimal must now be considered read-only
####2.1.0
#### 2.1.0
* 4/06/2014 Amend UMD
####2.0.3
#### 2.0.3
* 8/05/2014 Fix NaN toNumber
####2.0.2
#### 2.0.2
* 30/04/2014 Correct doc links
####2.0.1
#### 2.0.1
* 10/04/2014 Update npmignore
####2.0.0
#### 2.0.0
* 10/04/2014 Add `toSignificantDigits`
* Remove `toInteger`
* No arguments to `ceil`, `floor`, `round` and `trunc`
####1.0.1
#### 1.0.1
* 07/04/2014 Minor documentation clean-up
####1.0.0
#### 1.0.0
* 02/04/2014 Initial release

View File

@ -1,4 +1,4 @@
The MIT Expat Licence.
The MIT Licence.
Copyright (c) 2016 Michael Mclaughlin

View File

@ -4,10 +4,6 @@ An arbitrary-precision Decimal type for JavaScript.
<br>
[![Build Status](https://travis-ci.org/MikeMcl/decimal.js.svg)](https://travis-ci.org/MikeMcl/decimal.js)
*For a smaller library without the trigonometric functions see the
[v4.x.x](https://github.com/MikeMcl/decimal.js/tree/v4.x.x) branch where version 4 of this library
continues to be supported, or see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/), which is smaller still.*
<br>
## Features
@ -24,7 +20,7 @@ continues to be supported, or see [decimal.js-light](https://github.com/MikeMcl/
![API](https://raw.githubusercontent.com/MikeMcl/decimal.js/gh-pages/API.png)
The library is similar to [bignumber.js](https://github.com/MikeMcl/bignumber.js/), but here
precision is specified in terms of significant digits instead of decimal places, and all
precision is specified in terms of significant digits rather than decimal places, and all
calculations are rounded to the precision (similar to Python's decimal module) rather than just
those involving division.
@ -32,6 +28,9 @@ This library also adds the trigonometric functions, among others, and supports n
which makes it a significantly larger library than *bignumber.js* and the even smaller
[big.js](https://github.com/MikeMcl/big.js/).
For a lighter version of this library without the trigonometric functions see the
[v4.x.x](https://github.com/MikeMcl/decimal.js/tree/v4.x.x) branch where version 4 continues to be supported, or better, see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/), which is lighter still.
## Load
The library is the single JavaScript file *decimal.js* (or minified, *decimal.min.js*).
@ -153,7 +152,7 @@ applies to all Decimal numbers created from it.
```js
// Set the precision and rounding of the default Decimal constructor
Decimal.config({ precision: 5, rounding: 4 })
Decimal.set({ precision: 5, rounding: 4 })
// Create another Decimal constructor, optionally passing in a configuration object
Decimal10 = Decimal.clone({ precision: 10, rounding: 1 })
@ -217,6 +216,7 @@ npm run build
will create *decimal.min.js*, and a source map will also be added to the *doc* directory.
## Feedback
<a href='mailto:M8ch88l@gmail.com'>M8ch88l@gmail.com</a>
@ -225,6 +225,6 @@ BTC 16MjxmTB5EZxY5Uk9xyhfsu4n9gYxEJYkY
## Licence
MIT Expat.
MIT.
See *LICENCE.md*

View File

@ -1,7 +1,7 @@
{
"name": "decimal.js",
"main": "decimal.js",
"version": "6.0.0",
"version": "7.0.0",
"homepage": "https://github.com/MikeMcl/decimal.js",
"authors": [
"Michael Mclaughlin <M8ch88l@gmail.com>"

4
decimal.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -61,7 +61,7 @@ li span{float:right;margin-right:10px;color:#c0c0c0}
<a class='nav-title' href="#">API</a>
<b>CONSTRUCTOR</b>
<ul><li><a href="#decimal">Decimal</a></li></ul>
<ul><li><a href="#decimal"><strong>Decimal</strong></a></li></ul>
<a href="#methods">Methods</a>
<ul>
@ -76,8 +76,7 @@ li span{float:right;margin-right:10px;color:#c0c0c0}
<li><a href="#Datan2" >atan2</a></li>
<li><a href="#Dcbrt" >cbrt</a></li>
<li><a href="#Dceil" >ceil</a></li>
<li><a href="#Dclone" >clone</a></li>
<li><a href="#Dconfig" >config</a></li>
<li><a href="#Dclone" ><strong>clone</strong></a></li>
<li><a href="#Dcos" >cos</a></li>
<li><a href="#Dcosh" >cosh</a></li>
<li><a href="#Ddiv" >div</a></li>
@ -92,10 +91,11 @@ li span{float:right;margin-right:10px;color:#c0c0c0}
<li><a href="#Dmin" >min</a></li>
<li><a href="#Dmod" >mod</a></li>
<li><a href="#Dmul" >mul</a></li>
<li><a href="#DnoConflict">noConflict</a></li>
<li><a href="#DnoConflict"><strong>noConflict</strong></a></li>
<li><a href="#Dpow" >pow</a></li>
<li><a href="#Drandom" >random</a></li>
<li><a href="#Dround" >round</a></li>
<li><a href="#Dset" ><strong>set</strong></a></li>
<li><a href="#Dsign" >sign</a></li>
<li><a href="#Dsin" >sin</a></li>
<li><a href="#Dsinh" >sinh</a></li>
@ -442,10 +442,10 @@ a.equals(b) // true</pre>
<p><code>object</code>: <i>object</i></p>
<p>
Returns a new independent Decimal constructor with configuration settings as described by
<code>object</code> (see <a href='#Dconfig'><code>config</code></a>), or with the same
<code>object</code> (see <a href='#Dset'><code>set</code></a>), or with the same
settings as <code>this</code> Decimal constructor if <code>object</code> is omitted.
</p>
<pre>Decimal.config({ precision: 5 })
<pre>Decimal.set({ precision: 5 })
D9 = Decimal.clone({ precision: 9 })
a = new Decimal(1)
@ -456,7 +456,7 @@ b.div(3) // 0.333333333
// D9 = Decimal.clone({ precision: 9 }) is equivalent to:
D9 = Decimal.clone()
D9.config({ precision: 9 })</pre>
D9.set({ precision: 9 })</pre>
<p>
It is not inefficient in terms of memory usage to use multiple Decimal constructors as
functions are shared between them.
@ -464,45 +464,6 @@ D9.config({ precision: 9 })</pre>
<h5 id="Dconfig">
config<code class='inset'>.config(object) <i>&rArr; Decimal constructor</i></code>
</h5>
<p><code>object</code>: <i>object</i></p>
<p>
Configures the 'global' settings for <code>this</code> particular Decimal constructor, i.e.
the settings which apply to operations performed on the Decimal instances created by it.
</p>
<p>Returns <code>this</code> Decimal constructor.</p>
<p>
The configuration object, <code>object</code>, can contain some or all of the properties
described in detail at <a href="#constructor-properties">Properties</a> and shown in the
example below.
</p>
<p>
The values of the configuration object properties are checked for validity and then stored as
equivalently-named properties of <code>this</code> Decimal constructor.
</p>
<p>Throws on an invalid <code>object</code> or configuration property value.</p>
<pre>
// Defaults
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
maxE: 9e15,
minE: -9e15,
modulo: 1,
crypto: undefined
})</pre>
<p>
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 - which is not a problem if the user
knows that the checks are unnecessary.
</p>
<h5 id="Dcos">cos<code class='inset'>.cos(x) <i>&rArr; Decimal</i></code></h5>
<p><code>x</code>: <i>number|string|Decimal</i></p>
<p>See <code><a href='#cos'>cosine</a></code>.</p>
@ -710,13 +671,12 @@ a.equals(b) // true</pre>
</p>
<p>
If the value of <code>this</code> Decimal constructor's
<a href='#crypto'><code>crypto</code></a> property is <code>undefined</code> or
<code>true</code>, and the <code>crypto</code> object is available in the host environment,
the random digits of the return value are generated by either
<code>crypto.getRandomValues</code> (Web Cryptography API in modern browsers) or
<code>crypto.randomBytes</code> (Node.js), otherwise, if the the value of the property is
<code>false</code>, or the <code>crypto</code> object is not available, the return value is
generated by <code>Math.random</code> (fastest).
<a href='#crypto'><code>crypto</code></a> property is <code>true</code>, and the
<code>crypto</code> object is available in the host environment, the random digits of the
return value are generated by either <code>crypto.getRandomValues</code> (Web Cryptography API
in modern browsers) or <code>crypto.randomBytes</code> (Node.js), otherwise, if the the value
of the property is <code>false</code> the return value is generated by
<code>Math.random</code> (fastest).
</p>
<p>
If the value of <code>this</code> Decimal constructor's
@ -728,7 +688,7 @@ a.equals(b) // true</pre>
If one of the <code>crypto</code> methods is used, the value of the returned Decimal should be
cryptographically-secure and statistically indistinguishable from a random value.
</p>
<pre>Decimal.config({ precision: 10 })
<pre>Decimal.set({ precision: 10 })
Decimal.random() // '0.4117936847'
Decimal.random(20) // '0.78193327636914089009'</pre>
@ -743,6 +703,44 @@ a.equals(b) // true</pre>
<h5 id="Dset">set<code class='inset'>.set(object) <i>&rArr; Decimal constructor</i></code></h5>
<p><code>object</code>: <i>object</i></p>
<p>
Configures the 'global' settings for <code>this</code> particular Decimal constructor, i.e.
the settings which apply to operations performed on the Decimal instances created by it.
</p>
<p>Returns <code>this</code> Decimal constructor.</p>
<p>
The configuration object, <code>object</code>, can contain some or all of the properties
described in detail at <a href="#constructor-properties">Properties</a> and shown in the
example below.
</p>
<p>
The values of the configuration object properties are checked for validity and then stored as
equivalently-named properties of <code>this</code> Decimal constructor.
</p>
<p>Throws on an invalid <code>object</code> or configuration property value.</p>
<pre>
// Defaults
Decimal.set({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
maxE: 9e15,
minE: -9e15,
modulo: 1,
crypto: false
})</pre>
<p>
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
knows that the assingment is valid.
</p>
<pre>Decimal.precision = 40</pre>
<h5 id="Dsign">sign<code class='inset'>.sign(x) <i>&rArr; number</i></code></h5>
<p><code>x</code>: <i>number|string|Decimal</i></p>
<table>
@ -795,7 +793,7 @@ a.equals(b) // true</pre>
<p>See <a href='#sqrt'>squareRoot</a>.</p>
<pre>a = Decimal.sqrt(x)
b = new Decimal(x).sqrt()
a.equals(b) // true</pre>
a.equals(b) // true</pre>
@ -851,14 +849,14 @@ a.equals(b) // true</pre>
<a href='#maxE'><code>maxE</code></a>, <a href='#toExpNeg'><code>toExpNeg</code></a>,
<a href='#toExpPos'><code>toExpPos</code></a>, <a href='#modulo'><code>modulo</code></a>, and
<a href='#crypto'><code>crypto</code></a> are set using the
<a href='#Dconfig'><code>config</code></a> method.
<a href='#Dset'><code>set</code></a> method.
</p>
<p>
As simple object properties they can be set directly without using
<a href='#Dconfig'><code>config</code></a>, and it is fine to do so, but the values assigned
<a href='#Dset'><code>set</code></a>, and it is fine to do so, but the values assigned
will not then be checked for validity. For example:
</p>
<pre>Decimal.config({ precision: 0 })
<pre>Decimal.set({ precision: 0 })
// '[DecimalError] Invalid argument: precision: 0'
Decimal.precision = 0
@ -882,7 +880,7 @@ Decimal.precision = 0
<a href='#toNearest'><code>toNearest</code></a> and
<a href='#trunc'><code>truncated</code></a>.
</p>
<pre>Decimal.config({ precision: 5 })
<pre>Decimal.set({ precision: 5 })
Decimal.precision // 5</pre>
@ -910,8 +908,8 @@ Decimal.precision // 5</pre>
The <a href='#modes'>rounding modes</a> are available as enumerated properties of the
constructor.
</p>
<pre>Decimal.config({ rounding: Decimal.ROUND_UP })
Decimal.config({ rounding: 0 }) // equivalent
<pre>Decimal.set({ rounding: Decimal.ROUND_UP })
Decimal.set({ rounding: 0 }) // equivalent
Decimal.rounding // 0</pre>
@ -930,12 +928,12 @@ Decimal.rounding // 0</pre>
<p>
JavaScript numbers underflow to zero for exponents below <code>-324</code>.
</p>
<pre>Decimal.config({ minE: -500 })
<pre>Decimal.set({ minE: -500 })
Decimal.minE // -500
new Decimal('1e-500') // '1e-500'
new Decimal('9.9e-501') // '0'
Decimal.config({ minE: -3 })
Decimal.set({ minE: -3 })
new Decimal(0.001) // '0.01' e is -3
new Decimal(0.0001) // '0' e is -4</pre>
<p>
@ -959,12 +957,12 @@ new Decimal(0.0001) // '0' e is -4</pre>
<p>
JavaScript numbers overflow to <code>Infinity</code> for exponents above <code>308</code>.
</p>
<pre>Decimal.config({ maxE: 500 })
<pre>Decimal.set({ maxE: 500 })
Decimal.maxE // 500
new Decimal('9.999e500') // '9.999e+500'
new Decimal('1e501') // 'Infinity'
Decimal.config({ maxE: 4 })
Decimal.set({ maxE: 4 })
new Decimal(99999) // '99999' e is 4
new Decimal(100000) // 'Infinity'</pre>
<p>
@ -982,13 +980,13 @@ new Decimal(100000) // 'Infinity'</pre>
The negative exponent value at and below which <a href='#toString'><code>toString</code></a>
returns exponential notation.
</p>
<pre>Decimal.config({ toExpNeg: -7 })
<pre>Decimal.set({ toExpNeg: -7 })
Decimal.toExpNeg // -7
new Decimal(0.00000123) // '0.00000123' e is -6
new Decimal(0.000000123) // '1.23e-7'
// Always return exponential notation:
Decimal.config({ toExpNeg: 0 })</pre>
Decimal.set({ toExpNeg: 0 })</pre>
<p>
JavaScript numbers use exponential notation for negative exponents of <code>-7</code> and
below.
@ -1011,13 +1009,13 @@ Decimal.config({ toExpNeg: 0 })</pre>
The positive exponent value at and above which <a href='#toString'><code>toString</code></a>
returns exponential notation.
</p>
<pre>Decimal.config({ toExpPos: 2 })
<pre>Decimal.set({ toExpPos: 2 })
Decimal.toExpPos // 2
new Decimal(12.3) // '12.3' e is 1
new Decimal(123) // '1.23e+2'
// Always return exponential notation:
Decimal.config({ toExpPos: 0 })</pre>
Decimal.set({ toExpPos: 0 })</pre>
<p>
JavaScript numbers use exponential notation for positive exponents of <code>20</code> and
above.
@ -1084,23 +1082,23 @@ Decimal.config({ toExpPos: 0 })</pre>
<p>
The rounding/modulo modes are available as enumerated properties of the Decimal constructor.
</p>
<pre>Decimal.config({ modulo: Decimal.EUCLID })
Decimal.config({ modulo: 9 }) // equivalent
<pre>Decimal.set({ modulo: Decimal.EUCLID })
Decimal.set({ modulo: 9 }) // equivalent
Decimal.modulo // 9</pre>
<h5 id="crypto">crypto</h5>
<p>
<i>boolean</i>: <code>true/false/undefined</code><br /> Default value: <code>undefined</code>
<i>boolean</i>: <code>true/false</code><br /> Default value: <code>false</code>
</p>
<p>
The value that determines whether cryptographically-secure pseudo-random number generation is
used.
</p>
<p>See <a href='#Drandom'><code>random</code></a>.</p>
<pre>Decimal.crypto // undefined
Decimal.config({ crypto: true })
<pre>Decimal.crypto // false
Decimal.set({ crypto: true })
Decimal.crypto // true</pre>
@ -1144,8 +1142,8 @@ Decimal.crypto // true</pre>
<td>Not a rounding mode, see <a href='#modulo'>modulo</a></td>
</tr>
</table>
<pre>Decimal.config({ rounding: Decimal.ROUND_CEIL })
Decimal.config({ rounding: 2 }) // equivalent
<pre>Decimal.set({ rounding: Decimal.ROUND_CEIL })
Decimal.set({ rounding: 2 }) // equivalent
Decimal.rounding // 2</pre>
@ -1870,7 +1868,7 @@ y.sd(true) // '6'</pre>
<code>7</code>, i.e. <a href='#modes'><code>ROUND_HALF_CEIL</code></a>.
</p>
<pre>
Decimal.config({ rounding: 4 })
Decimal.set({ rounding: 4 })
x = 1234.5
x.round() // '1235'
@ -2311,7 +2309,7 @@ new Decimal(1217652.23).pow('98765.489305603941')
An example of incorrect rounding:
</p>
<pre>
Decimal.config({ precision: 20, rounding: 1 })
Decimal.set({ precision: 20, rounding: 1 })
new Decimal(28).pow('6.166675020000903537297764507632802193308677149')
// 839756321.64088511</pre>
<p>As the exact mathematical result begins</p>
@ -2383,7 +2381,7 @@ y.toPrecision(5) // '45.600'</pre>
</p>
<p>Throws on an invalid <code>sd</code> or <code>rm</code> value.</p>
<pre>
Decimal.config({ precision: 5, rounding: 4 })
Decimal.set({ precision: 5, rounding: 4 })
x = new Decimal(9876.54321)
x.toSignificantDigits() // '9876.5'
@ -2405,10 +2403,10 @@ x // '9876.54321'</pre>
<pre>
x = new Decimal(750000)
x.toString() // '750000'
Decimal.config({ toExpPos: 5 })
Decimal.set({ toExpPos: 5 })
x.toString() // '7.5e+5'
Decimal.config({ precision: 4 });
Decimal.set({ precision: 4 })
y = new Decimal('1.23456789')
y.toString() // '1.23456789'</pre>

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "decimal.js",
"description": "An arbitrary-precision Decimal type for JavaScript.",
"version": "6.0.0",
"version": "7.0.0",
"keywords": [
"arbitrary",
"precision",
@ -28,6 +28,6 @@
"license": "MIT",
"scripts": {
"test": "node ./test/test.js",
"build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v6.0.0 https://github.com/MikeMcl/decimal.js/LICENCE */\""
"build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v7.0.0 https://github.com/MikeMcl/decimal.js/LICENCE */\""
}
}

View File

@ -61,7 +61,7 @@ T('config', function () {
toExpPos: 1000,
minE: -1e9,
maxE: 1e9,
crypto: true,
//crypto: true, // requires crypto object
modulo: 4
});
@ -71,7 +71,7 @@ T('config', function () {
t(Decimal.toExpPos === 1000);
t(Decimal.minE === -1e9);
t(Decimal.maxE === 1e9);
t(Decimal.crypto === true || Decimal.crypto === false);
//t(Decimal.crypto === true); // requires crypto object
t(Decimal.modulo === 4);
Decimal.config({
@ -277,15 +277,11 @@ T('config', function () {
T.assertEqual(expected, Decimal.crypto);
}
// crypto was set true above, but it will have remained false if
// there is no crypto.getRandomValues or crypto.randomBytes.
var cryptoVal = Decimal.crypto;
t(void 0, {crypto: void 0});
t(false, {crypto: void 0});
t(false, {crypto: 0});
t(cryptoVal, {crypto: 1});
//t(true, {crypto: 1}); // requires crypto object
t(false, {crypto: false});
t(cryptoVal, {crypto: true});
//t(true, {crypto: true}); // requires crypto object
tx(function () {Decimal.config({crypto: 'hiya'})}, "crypto: 'hiya'");
tx(function () {Decimal.config({crypto: 'true'})}, "crypto: 'true'");
@ -301,7 +297,7 @@ T('config', function () {
tx(function () {Decimal.config({crypto: NaN})}, "crypto: NaN");
tx(function () {Decimal.config({crypto: Infinity})}, "crypto: Infinity");
t(void 0, {crypto: void 0});
T.assertEqual(false, Decimal.crypto);
// modulo
@ -341,4 +337,6 @@ T('config', function () {
tx(function () {Decimal.config({modulo: Infinity})}, "modulo: Infinity");
t(9, {modulo: void 0});
T.assertEqual(Decimal.set, Decimal.config);
});

View File

@ -83,7 +83,8 @@
if (!module) {
time = new Date() - time;
document.body.innerHTML +=
'<br>&nbsp;In total, ' + passed + ' of ' + total + ' tests passed in ' + (time / 1e3) + ' secs.<br>';
'<br>&nbsp;In total, ' + passed + ' of ' + total + ' tests passed in ' +
(time / 1e3) + ' secs.<br>';
document.body.scrollIntoView(false);
return;
}