Initial commit. Publish.

This commit is contained in:
Michael Mclaughlin 2012-11-08 20:02:27 +00:00
commit d6b8f29a4a
47 changed files with 74458 additions and 0 deletions

23
LICENCE Normal file
View File

@ -0,0 +1,23 @@
The MIT Expat Licence.
Copyright (c) 2012 Michael Mclaughlin
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

203
README.md Normal file
View File

@ -0,0 +1,203 @@
# bignumber.js #
A Javascript library for arbitrary-precision arithmetic.
## Features
- Faster, smaller, and perhaps easier-to-use than Javascript versions of Java's BigDecimal
- 5 KB minified and gzipped
- Simple API but full-featured
- Works with numbers with fraction digits in bases from 2 to 36 inclusive
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of Javascript's Number type
- Includes a `toFraction` and a `squareRoot` method
- Stores values in an accessible decimal floating point format
- No dependencies
- Comprehensive documentation and test set
If a smaller, simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
It's half the size with half the methods and only works with decimal numbers; it also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
## Load
The library is the single Javascript file *bignumber.js*
(or *bignumber.min.js*, which is *bignumber.js* minified using uglify-js).
It can be loaded via a script tag in an HTML document for the browser
<script src='./relative/path/to/bignumber.js'></script>
or as a CommonJS, [Node.js](http://nodejs.org) or AMD module using `require`.
For Node, put the *bignumber.js* file into the same directory as the file that is requiring it and use
var BigNumber = require('./bignumber');
or put it in a *node_modules* directory within the directory and use
var BigNumber = require('bignumber');
To load with AMD loader libraries such as [requireJS](http://requirejs.org/):
require(['bignumber'], function(BigNumber) {
// Use BigNumber here in local scope. No global BigNumber.
});
## Use
*In all examples below, `var`, semicolons and `toString` calls are not shown.
If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
The library exports a single function: BigNumber, the constructor of BigNumber instances.
It accepts a value of type Number, String or Object,
x = new BigNumber(123.4567)
y = BigNumber('123456.7e-3') // 'new' is optional
z = new BigNumber(x)
x.equals(y) && y.equals(z) && x.equals(z) // true
and a base from 2 to 36 inclusive can be specified.
x = new BigNumber(1011, 2) // "11"
y = new BigNumber('zz.9', 36) // "1295.25"
z = x.plus(y) // "1306.25"
A BigNumber is immutable in the sense that it is not changed by its methods.
0.3 - 0.1 // 0.19999999999999998
x = new BigNumber(0.3)
x.minus(0.1) // "0.2"
x // "0.3"
The methods that return a BigNumber can be chained.
x.dividedBy(y).plus(z).times(9).floor()
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').ceil()
Method names over 5 letters in length have a shorter alias.
x.squareRoot().dividedBy(y).toPower(3).equals(x.sqrt().div(y).pow(3)) // true
x.cmp(y.mod(z).neg()) == 1 && x.comparedTo(y.modulo(z).negated()) == 1 // true
Like Javascript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods
x = new BigNumber(255.5)
x.toExponential(5) // "2.55500e+2"
x.toFixed(5) // "255.50000"
x.toPrecision(5) // "255.50"
and a base can be specified for `toString`.
x.toString(16) // "ff.8"
The maximum number of decimal places and the rounding mode for division, square root, base conversion, and negative power operations is set by a configuration object passed to the `config` method of the `BigNumber` constructor.
The other arithmetic operations always give the exact result.
BigNumber.config({ DECIMAL_PLACES : 10, ROUNDING_MODE : 4 })
// Alternatively, BigNumber.config( 10, 4 );
x = new BigNumber(2);
y = new BigNumber(3);
z = x.div(y) // "0.6666666667"
z.sqrt() // "0.8164965809"
z.pow(-3) // "3.3749999995"
z.toString(2) // "0.1010101011"
x.times(y) // "1.15470053845773502692"
There is a `toFraction` method with an optional *maximum denominator* argument
y = new BigNumber(355)
pi = y.dividedBy(113) // "3.1415929204"
pi.toFraction() // [ "7853982301", "2500000000" ]
pi.toFraction(1000) // [ "355", "113" ]
and `isNaN` and `isFinite` methods, as `NaN` and `Infinity` are valid `BigNumber` values.
x = new BigNumber(NaN) // "NaN"
y = new BigNumber(Infinity) // "Infinity"
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
x = new BigNumber(-123.456);
x.c // "1,2,3,4,5,6" coefficient (i.e. significand)
x.e // 2 exponent
x.s // -1 sign
For futher information see the API reference in the *doc* folder.
## Test
The *test* directory contains the test scripts for each method.
The tests can be run with Node or a browser.
For a quick test of all the methods, from a command-line shell at the *test/* directory
$ node quick-test
To test a single method in more depth, e.g.
$ node toFraction
To test all the methods in more depth
$ node every-test
For the browser, see *quick-test.html*, *single-test.html* and *every-test.html* in the *test/browser* directory.
*bignumber-vs-number.html* enables some of the methods of bignumber.js to be compared with those of Javascript's Number type.
## Performance
The *perf* directory contains two applications and a *lib* directory containing the BigDecimal libraries used by both.
*bignumber-vs-bigdecimal.html* tests the performance of bignumber.js against the Javascript translations of two versions of BigDecimal, its use should be more or less self-explanatory.
(The GWT version doesn't work in IE 6.)
* GWT: java.math.BigDecimal
<https://github.com/iriscouch/bigdecimal.js>
* ICU4J: com.ibm.icu.math.BigDecimal
<https://github.com/dtrebbien/BigDecimal.js>
The BigDecimal in Node's npm registry is the GWT version; unfortunately, it has serious bugs, see the Node script *perf/lib/bigdecimal_GWT/bugs.js for examples of flaws in its *remainder*, *divide* and *compareTo* methods.
*bigtime.js* is a Node command-line application which tests the performance of bignumber.js against the GWT version of BigDecimal from the npm registry.
For example, to compare the time taken by the bignumber.js `plus` method and the BigDecimal `add` method:
$ node bigtime plus 10000 40
This will time 10000 calls to each, using operands of up to 40 random digits and will check that the results match.
For help:
$ node bigtime -h
See the README in the directory for more information.
## Build
I.e. minify.
For Node, if uglify-js is installed globally ( `npm install uglify-js -g` ) then
uglifyjs -o ./bignumber.min.js ./bignumber.js
will create *bignumber.min.js*.
## Feedback
Bugs/issues/comments to:
Michael Mclaughlin
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
## Licence
See LICENCE.
## Change Log
####1.0.0
* 8/11/2012
* Initial release

1901
bignumber.js Normal file

File diff suppressed because it is too large Load Diff

1
bignumber.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1704
doc/API.html Normal file

File diff suppressed because it is too large Load Diff

45
perf/README.txt Normal file
View File

@ -0,0 +1,45 @@
bigtime.js
==========
* Creates random numbers and BigNumber and BigDecimal objects in batches.
* UNLIKELY TO RUN OUT OF MEMORY.
* Doesn't show separate times for object creation and method calls.
* Tests methods with one or two operands (i.e. includes abs and negate).
* Doesn't indicate random number creation completion.
* Doesn't calculate average number of digits of operands.
* Creates random numbers in exponential notation.
bigtime-OOM.js
==============
* Creates random numbers and BigNumber and BigDecimal objects all in one go.
* MAY RUN OUT OF MEMORY, e.g. if iterations > 500000 and random digits > 40.
* SHOWS SEPARATE TIMES FOR OBJECT CREATION AND METHOD CALLS.
* Only tests methods with two operands (i.e. no abs or negate).
* Indicates random number creation completion.
* Calculates average number of digits of operands.
* Creates random numbers in normal notation.
In general, bigtime.js is recommended over bigtime-OOM.js, which is included as
separate timings for object creation and method calls may be preferred.
Usage
=====
For help:
$ node bigtime -h
Examples:
Compare the time taken by the BigNumber plus method and the BigDecimal add method.
Time 10000 calls to each.
Use operands of up to 40 random digits (each unique for each iteration).
Check that the BigNumber results match the BigDecimal results.
$ node bigtime plus 10000 40

View File

@ -0,0 +1,699 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<meta name="Author" content="M Mclaughlin">
<title>Testing BigNumber</title>
<style>
body {margin: 0; padding: 0; font-family: Calibri, Arial, Sans-Serif;}
div {margin: 1em 0;}
h1, #counter {text-align: center; background-color: rgb(225, 225, 225);
margin-top: 1em; padding: 0.2em; font-size: 1.2em;}
a {color: rgb(0, 153, 255); margin: 0 0.6em;}
.links {position: fixed; bottom: 1em; right: 2em; font-size: 0.8em;}
.form, #time {width: 36em; margin: 0 auto;}
.form {text-align: left; margin-top: 1.4em;}
.random input {margin-left: 1em;}
.small {font-size: 0.9em;}
.methods {margin: 1em auto; width: 18em;}
.iterations input, .left {margin-left: 1.6em;}
.info span {margin-left: 1.6em; font-size: 0.9em;}
.info {margin-top: 1.6em;}
.random input, .iterations input {margin-right: 0.3em;}
.random label, .iterations label, .bigd label {font-size: 0.9em;
margin-left: 0.1em;}
.methods label {width: 5em; margin-left: 0.2em; display: inline-block;}
.methods label.right {width: 2em;}
.red {color: red; font-size: 1.1em; font-weight: bold;}
button {width: 10em; height: 2em;}
#dp, #r, #digits, #reps {margin-left: 0.8em;}
#bigint {font-style: italic; display: none;}
#gwt, #icu4j, #bd, #bigint {margin-left: 1.5em;}
#division {display: none;}
#counter {font-size: 2em; background-color: rgb(235, 235, 235);}
#time {text-align: center;}
#results {margin: 0 1.4em;}
</style>
<script src='../bignumber.js'></script>
<script src='./lib/bigdecimal_GWT/bigdecimal.js'></script>
</head>
<body>
<h1>Testing BigNumber against BigDecimal</h1>
<div class='form'>
<div class='methods'>
<input type='radio' id=0 name=1/><label for=0>plus</label>
<input type='radio' id=3 name=1/><label for=3>div</label>
<input type='radio' id=6 name=1/><label for=6 class='right'>abs</label>
<br>
<input type='radio' id=1 name=1/><label for=1>minus</label>
<input type='radio' id=4 name=1/><label for=4>mod</label>
<input type='radio' id=7 name=1/><label for=7 class='right'>neg</label>
<br>
<input type='radio' id=2 name=1/><label for=2>times</label>
<input type='radio' id=5 name=1/><label for=5>cmp</label>
<input type='radio' id=8 name=1/><label for=8 class='right'>pow</label>
</div>
<div class='bigd'>
<span>BigDecimal:</span>
<input type='radio' name=2 id='gwt' /><label for='gwt'>GWT</label>
<input type='radio' name=2 id='icu4j' /><label for='icu4j'>ICU4J</label>
<span id='bigint'>BigInteger</span>
<span id='bd'>add</span>
</div>
<div class='random'>
Random number digits:<input type='text' id='digits' size=12 />
<input type='radio' name=3 id='fix' /><label for='fix'>Fixed</label>
<input type='radio' name=3 id='max' /><label for='max'>Max</label>
<input type='checkbox' id='int' /><label for='int'>Integers only</label>
</div>
<div id='division'>
<span>Decimal places:<input type='text' id='dp' size=9 /></span>
<span class='left'>Rounding:<select id='r'>
<option>UP</option>
<option>DOWN</option>
<option>CEIL</option>
<option>FLOOR</option>
<option>HALF_UP</option>
<option>HALF_DOWN</option>
<option>HALF_EVEN</option>
</select></span>
</div>
<div class='iterations'>
Iterations:<input type='text' id='reps' size=11 />
<input type='checkbox' id='show'/><label for='show'>Show all (no timing)</label>
</div>
<div class='info'>
<button id='start'>Start</button>
<span>Click a method to stop</span>
<span>Press space bar to pause/unpause</span>
</div>
</div>
<div id='counter'>0</div>
<div id='time'></div>
<div id='results'></div>
<div class='links'>
<a href='https://github.com/MikeMcl/bignumber.js' target='_blank'>BigNumber</a>
<a href='https://github.com/iriscouch/bigdecimal.js' target='_blank'>GWT</a>
<a href='https://github.com/dtrebbien/BigDecimal.js/tree/' target='_blank'>ICU4J</a>
</div>
<script>
var i, completedReps, targetReps, cycleReps, cycleTime, prevCycleReps, cycleLimit,
maxDigits, isFixed, isIntOnly, decimalPlaces, rounding, calcTimeout,
counterTimeout, script, isGWT, BigDecimal_GWT, BigDecimal_ICU4J,
bdM, bdTotal, bnM, bnTotal,
bdMs = ['add', 'subtract', 'multiply', 'divide', 'remainder', 'compareTo',
'abs', 'negate', 'pow'],
bnMs = ['plus', 'minus', 'times', 'div', 'mod', 'cmp', 'abs', 'neg', 'pow'],
lastRounding = 4,
pause = false,
up = true,
timingVisible = false,
showAll = false,
// EDIT DEFAULTS HERE
DEFAULT_REPS = 10000,
DEFAULT_DIGITS = 20,
DEFAULT_DECIMAL_PLACES = 20,
DEFAULT_ROUNDING = 4,
MAX_POWER = 20,
CHANCE_NEGATIVE = 0.5, // 0 (never) to 1 (always)
CHANCE_INTEGER = 0.2, // 0 (never) to 1 (always)
MAX_RANDOM_EXPONENT = 100,
SPACE_BAR = 32,
ICU4J_URL = './lib/bigdecimal_ICU4J/BigDecimal-all-last.js',
//
$ = function (id) {return document.getElementById(id)},
$INPUTS = document.getElementsByTagName('input'),
$BD = $('bd'),
$BIGINT = $('bigint'),
$DIGITS = $('digits'),
$GWT = $('gwt'),
$ICU4J = $('icu4j'),
$FIX = $('fix'),
$MAX = $('max'),
$INT = $('int'),
$DIV = $('division'),
$DP = $('dp'),
$R = $('r'),
$REPS = $('reps'),
$SHOW = $('show'),
$START = $('start'),
$COUNTER = $('counter'),
$TIME = $('time'),
$RESULTS = $('results'),
// Get random number in normal notation.
getRandom = function () {
var z,
i = 0,
// n is the number of digits - 1
n = isFixed ? maxDigits - 1 : Math.random() * (maxDigits || 1) | 0,
r = ( Math.random() * 10 | 0 ) + '';
if (n) {
if (r == '0')
r = isIntOnly ? ( ( Math.random() * 9 | 0 ) + 1 ) + '' : (z = r + '.');
for ( ; i++ < n; r += Math.random() * 10 | 0 ){}
if (!z && !isIntOnly && Math.random() > CHANCE_INTEGER) {
r = r.slice( 0, i = (Math.random() * n | 0) + 1 ) +
'.' + r.slice(i);
}
}
// Avoid division by zero error with division and modulo
if ((bdM == 'divide' || bdM == 'remainder') && parseFloat(r) === 0)
r = ( ( Math.random() * 9 | 0 ) + 1 ) + '';
return Math.random() > CHANCE_NEGATIVE ? r : '-' + r;
},
// Get random number in exponential notation (if isIntOnly is false).
// GWT BigDecimal BigInteger does not accept exponential notation.
//getRandom = function () {
// var i = 0,
// // n is the number of significant digits - 1
// n = isFixed ? maxDigits - 1 : Math.random() * (maxDigits || 1) | 0,
// r = ( ( Math.random() * 9 | 0 ) + 1 ) + '';
//
// for (; i++ < n; r += Math.random() * 10 | 0 ){}
//
// if ( !isIntOnly ) {
//
// // Add exponent.
// r += 'e' + ( Math.random() > 0.5 ? '+' : '-' ) +
// ( Math.random() * MAX_RANDOM_EXPONENT | 0 );
// }
//
// return Math.random() > CHANCE_NEGATIVE ? r : '-' + r
//},
showTimings = function () {
var i, bdS, bnS,
sp = '',
r = bnTotal < bdTotal
? (bnTotal ? bdTotal / bnTotal : bdTotal)
: (bdTotal ? bnTotal / bdTotal : bnTotal);
bdS = 'BigDecimal: ' + (bdTotal || '<1');
bnS = 'BigNumber: ' + (bnTotal || '<1');
for ( i = bdS.length - bnS.length; i-- > 0; sp += '&nbsp;'){}
bnS = 'BigNumber: ' + sp + (bnTotal || '<1');
$TIME.innerHTML =
'No mismatches<div>' + bdS + ' ms<br>' + bnS + ' ms</div>' +
((r = parseFloat(r.toFixed(1))) > 1
? 'Big' + (bnTotal < bdTotal ? 'Number' : 'Decimal')
+ ' was ' + r + ' times faster'
: 'Times approximately equal');
},
clear = function () {
clearTimeout(calcTimeout);
clearTimeout(counterTimeout);
$COUNTER.style.textDecoration = 'none';
$COUNTER.innerHTML = '0';
$TIME.innerHTML = $RESULTS.innerHTML = '';
$START.innerHTML = 'Start';
},
begin = function () {
var i;
clear();
targetReps = +$REPS.value;
if (!(targetReps > 0)) return;
$START.innerHTML = 'Restart';
i = +$DIGITS.value;
$DIGITS.value = maxDigits = i && isFinite(i) ? i : DEFAULT_DIGITS;
for (i = 0; i < 9; i++) {
if ($INPUTS[i].checked) {
bnM = bnMs[$INPUTS[i].id];
bdM = bdMs[$INPUTS[i].id];
break;
}
}
if (bdM == 'divide') {
i = +$DP.value;
$DP.value = decimalPlaces = isFinite(i) ? i : DEFAULT_DECIMAL_PLACES;
rounding = $R.selectedIndex;
BigNumber.config(decimalPlaces, rounding);
}
isFixed = $FIX.checked;
isIntOnly = $INT.checked;
showAll = $SHOW.checked;
BigDecimal = (isGWT = $GWT.checked)
? (isIntOnly ? BigInteger : BigDecimal_GWT)
: BigDecimal_ICU4J;
prevCycleReps = cycleLimit = completedReps = bdTotal = bnTotal = 0;
pause = false;
cycleReps = showAll ? 1 : 0.5;
cycleTime = +new Date();
setTimeout(updateCounter, 0);
},
updateCounter = function () {
if (pause) {
if (!timingVisible && !showAll) {
showTimings();
timingVisible = true;
}
counterTimeout = setTimeout(updateCounter, 50);
return
}
$COUNTER.innerHTML = completedReps;
if (completedReps < targetReps) {
if (timingVisible) {
$TIME.innerHTML = '';
timingVisible = false;
}
if (!showAll) {
// Adjust cycleReps so counter is updated every second-ish
if (prevCycleReps != cycleReps) {
// cycleReps too low
if (+new Date() - cycleTime < 1e3) {
prevCycleReps = cycleReps;
if (cycleLimit) {
cycleReps += ((cycleLimit - cycleReps) / 2);
} else {
cycleReps *= 2;
}
// cycleReps too high
} else {
cycleLimit = cycleReps;
cycleReps -= ((cycleReps - prevCycleReps) / 2);
}
cycleReps = Math.floor(cycleReps) || 1;
cycleTime = +new Date();
}
if (completedReps + cycleReps > targetReps) {
cycleReps = targetReps - completedReps;
}
}
completedReps += cycleReps;
calcTimeout = setTimeout(calc, 0);
// Finished - show timings summary
} else {
$START.innerHTML = 'Start';
$COUNTER.style.textDecoration = 'underline';
if (!showAll) {
showTimings();
}
}
},
calc = function () {
var start, bdT, bnT, bdR, bnR,
xs = [cycleReps],
ys = [cycleReps],
bdRs = [cycleReps],
bnRs = [cycleReps];
// GENERATE RANDOM OPERANDS
for (i = 0; i < cycleReps; i++) {
xs[i] = getRandom();
}
if (bdM == 'pow') {
// GWT pow argument must be Number type and integer
if (isGWT) {
for (i = 0; i < cycleReps; i++) {
ys[i] = Math.floor(Math.random() * (MAX_POWER + 1));
}
// ICU4J pow argument must be BigDecimal
} else {
for (i = 0; i < cycleReps; i++) {
ys[i] = Math.floor(Math.random() * (MAX_POWER + 1)) + '';
}
}
// No second operand needed for abs and negate
} else if (bdM != 'abs' && bdM != 'negate') {
for (i = 0; i < cycleReps; i++) {
ys[i] = getRandom();
}
}
//********************************************************************//
//************************** START TIMING ****************************//
//********************************************************************//
// BIGDECIMAL
if (bdM == 'divide') {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](new BigDecimal(ys[i]),
decimalPlaces, rounding);
}
bdT = +new Date() - start;
// GWT pow argument must be Number type and integer
} else if (bdM == 'pow' && isGWT) {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](ys[i]);
}
bdT = +new Date() - start;
} else if (bdM == 'abs' || bdM == 'negate') {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM]();
}
bdT = +new Date() - start;
} else {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](new BigDecimal(ys[i]));
}
bdT = +new Date() - start;
}
// BIGNUM
if (bdM == 'pow') {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bnRs[i] = new BigNumber(xs[i])[bnM](ys[i]);
}
bnT = +new Date() - start;
} else if (bdM == 'abs' || bdM == 'negate') {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bnRs[i] = new BigNumber(xs[i])[bnM]();
}
bnT = +new Date() - start;
} else {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bnRs[i] = new BigNumber(xs[i])[bnM](new BigNumber(ys[i]));
}
bnT = +new Date() - start;
}
//********************************************************************//
//**************************** END TIMING ****************************//
//********************************************************************//
// CHECK FOR MISMATCHES
for (i = 0; i < cycleReps; i++) {
bnR = bnRs[i].toString();
// Remove any trailing zeros from BigDecimal result
if (isGWT) {
bdR = bdM == 'compareTo' || isIntOnly
? bdRs[i].toString()
: bdRs[i].stripTrailingZeros().toPlainString();
} else {
// No toPlainString() or stripTrailingZeros() in ICU4J
bdR = bdRs[i].toString();
if (bdR.indexOf('.') != -1) {
bdR = bdR.replace(/\.?0+$/, '');
}
}
if (bdR !== bnR) {
$RESULTS.innerHTML =
'<span class="red">Breaking on first mismatch:</span>' +
'<br><br>' +xs[i] + '<br>' + bnM + '<br>' + ys[i] +
'<br><br>BigDecimal<br>' + bdR + '<br>' + bnR + '<br>BigNumber';
if (bdM == 'divide') {
$RESULTS.innerHTML += '<br><br>Decimal places: ' +
decimalPlaces + '<br>Rounding mode: ' + rounding;
}
return;
} else if (showAll) {
$RESULTS.innerHTML = xs[i] + '<br>' + bnM + '<br>' + ys[i] +
'<br><br>BigDecimal<br>' + bdR + '<br>' + bnR + '<br>BigNumber';
}
}
bdTotal += bdT;
bnTotal += bnT;
updateCounter();
};
// EVENT HANDLERS
document.onkeyup = function (evt) {
evt = evt || window.event;
if ((evt.keyCode || evt.which) == SPACE_BAR) {
up = true;
}
};
document.onkeydown = function (evt) {
evt = evt || window.event;
if (up && (evt.keyCode || evt.which) == SPACE_BAR) {
pause = !pause;
up = false;
}
};
// BigNumber methods' radio buttons' event handlers
for (i = 0; i < 9; i++) {
$INPUTS[i].checked = false;
$INPUTS[i].disabled = false;
$INPUTS[i].onclick = function () {
clear();
lastRounding = $R.options.selectedIndex;
$DIV.style.display = 'none';
bnM = bnMs[this.id];
$BD.innerHTML = bdM = bdMs[this.id];
};
}
$INPUTS[1].onclick = function () {
clear();
$R.options.selectedIndex = lastRounding;
$DIV.style.display = 'block';
bnM = bnMs[this.id];
$BD.innerHTML = bdM = bdMs[this.id];
};
// Show/hide BigInteger and disable/un-disable division accordingly as BigInteger
// throws an exception if division gives "no exact representable decimal result"
$INT.onclick = function () {
if (this.checked && $GWT.checked) {
if ($INPUTS[1].checked) {
$INPUTS[1].checked = false;
$INPUTS[0].checked = true;
$BD.innerHTML = bdMs[$INPUTS[0].id];
$DIV.style.display = 'none';
}
$INPUTS[1].disabled = true;
$BIGINT.style.display = 'inline';
} else {
$INPUTS[1].disabled = false;
$BIGINT.style.display = 'none';
}
};
$ICU4J.onclick = function () {
$INPUTS[1].disabled = false;
$BIGINT.style.display = 'none';
};
$GWT.onclick = function () {
if ($INT.checked) {
if ($INPUTS[1].checked) {
$INPUTS[1].checked = false;
$INPUTS[0].checked = true;
$BD.innerHTML = bdMs[$INPUTS[0].id];
$DIV.style.display = 'none';
}
$INPUTS[1].disabled = true;
$BIGINT.style.display = 'inline';
}
};
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : false,
RANGE : 1E9,
EXPONENTIAL_AT : 1E9
});
// Set defaults
$MAX.checked = $INPUTS[0].checked = $GWT.checked = true;
$SHOW.checked = $INT.checked = false;
$REPS.value = DEFAULT_REPS;
$DIGITS.value = DEFAULT_DIGITS;
$DP.value = DEFAULT_DECIMAL_PLACES;
$R.option = DEFAULT_ROUNDING;
BigDecimal_GWT = BigDecimal;
BigDecimal = undefined;
// Load ICU4J BigDecimal
script = document.createElement("script");
script.src = ICU4J_URL;
script.onload = script.onreadystatechange = function () {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
script = null;
BigDecimal_ICU4J = BigDecimal;
$START.onmousedown = begin;
}
};
document.getElementsByTagName("head")[0].appendChild(script);
/*
NOTES:
ICU4J
=====
IBM java package: com.ibm.icu.math
pow's argument must be a BigDecimal.
Among other differences, doesn't have .toPlainString() or .stripTrailingZeros().
Exports BigDecimal only.
Much faster than gwt on Firefox, on Chrome it varies with the method.
GWT
===
Java standard class library: java.math.BigDecimal
Exports:
RoundingMode
MathContext
BigDecimal
BigInteger
BigDecimal properties:
ROUND_CEILING
ROUND_DOWN
ROUND_FLOOR
ROUND_HALF_DOWN
ROUND_HALF_EVEN
ROUND_HALF_UP
ROUND_UNNECESSARY
ROUND_UP
__init__
valueOf
log
logObj
ONE
TEN
ZERO
BigDecimal instance properties/methods:
( for (var i in new BigDecimal('1').__gwt_instance.__gwtex_wrap) {...} )
byteValueExact
compareTo
doubleValue
equals
floatValue
hashCode
intValue
intValueExact
max
min
movePointLeft
movePointRight
precision
round
scale
scaleByPowerOfTen
shortValueExact
signum
stripTrailingZeros
toBigInteger
toBigIntegerExact
toEngineeringString
toPlainString
toString
ulp
unscaledValue
longValue
longValueExact
abs
add
divide
divideToIntegralValue
multiply
negate
plus
pow
remainder
setScale
subtract
divideAndRemainder
*/
</script>
</body>
</html>

366
perf/bigtime-OOM.js Normal file
View File

@ -0,0 +1,366 @@
var arg, i, max, method, methodIndex, decimalPlaces,
reps, rounding, start, timesEqual, Xs, Ys,
bdM, bdMT, bdOT, bdRs, bdXs, bdYs,
bnM, bnMT, bnOT, bnRs, bnXs, bnYs,
memoryUsage, showMemory, bnR, bdR,
prevRss, prevHeapUsed, prevHeapTotal,
args = process.argv.splice(2),
BigDecimal = require('./lib/bigdecimal_GWT/bigdecimal').BigDecimal,
BigNumber = require('../bignumber'),
bdMs = ['add', 'subtract', 'multiply', 'divide', 'remainder', 'compareTo', 'pow'],
bnMs1 = ['plus', 'minus', 'times', 'dividedBy', 'modulo', 'comparedTo', 'toPower'],
bnMs2 = ['', '', '', 'div', 'mod', 'cmp', ''],
Ms = [bdMs, bnMs1, bnMs2],
allMs = [].concat.apply([], Ms),
expTotal = 0,
total = 0,
ALWAYS_SHOW_MEMORY = false,
DEFAULT_MAX_DIGITS = 20,
DEFAULT_POW_MAX_DIGITS = 20,
DEFAULT_REPS = 1e4,
DEFAULT_POW_REPS = 1e2,
DEFAULT_PLACES = 20,
MAX_POWER = 50,
getRandom = function (maxDigits) {
var i = 0, z,
// number of digits - 1
n = Math.random() * ( maxDigits || 1 ) | 0,
r = ( Math.random() * 10 | 0 ) + '';
if ( n ) {
if ( z = r === '0' ) {
r += '.';
}
for ( ; i++ < n; r += Math.random() * 10 | 0 ){}
// 20% chance of integer
if ( !z && Math.random() > 0.2 )
r = r.slice( 0, i = ( Math.random() * n | 0 ) + 1 ) + '.' + r.slice(i);
}
// Avoid 'division by zero' error with division and modulo.
if ((bdM == 'divide' || bdM == 'remainder') && parseFloat(r) === 0)
r = ( ( Math.random() * 9 | 0 ) + 1 ) + '';
total += n + 1;
// 50% chance of negative
return Math.random() > 0.5 ? r : '-' + r;
},
pad = function (str) {
str += '... ';
while (str.length < 26) str += ' ';
return str;
},
getFastest = function (bn, bd) {
var r;
if (Math.abs(bn - bd) > 2) {
r = 'Big' + ((bn < bd)
? 'Number ' + (bn ? parseFloat((bd / bn).toFixed(1)) : bd)
: 'Decimal ' + (bd ? parseFloat((bn / bd).toFixed(1)) : bn)) +
' times faster';
} else {
timesEqual = 1;
r = 'Times approximately equal';
}
return r;
},
showMemoryChange = function () {
if (showMemory) {
memoryUsage = process.memoryUsage();
var rss = memoryUsage.rss,
heapUsed = memoryUsage.heapUsed,
heapTotal = memoryUsage.heapTotal;
console.log(' Change in memory usage: ' +
' rss: ' + toKB(rss - prevRss) +
', hU: ' + toKB(heapUsed - prevHeapUsed) +
', hT: ' + toKB(heapTotal - prevHeapTotal));
prevRss = rss; prevHeapUsed = heapUsed; prevHeapTotal = heapTotal;
}
},
toKB = function (m) {
return parseFloat((m / 1024).toFixed(1)) + ' KB';
};
// PARSE COMMAND LINE AND SHOW HELP
if (arg = args[0], typeof arg != 'undefined' && !isFinite(arg) &&
allMs.indexOf(arg) == -1 && !/^-*m$/i.test(arg)) {
console.log(
'\n node bigtime-OOM [METHOD] [METHOD CALLS [MAX DIGITS [DECIMAL PLACES]]]\n' +
'\n METHOD: The method to be timed and compared with the automatically' +
'\n chosen corresponding method from BigDecimal or BigNumber\n' +
'\n BigDecimal: add subtract multiply divide remainder compareTo pow' +
'\n BigNumber: plus minus times dividedBy modulo comparedTo toPower' +
'\n (div mod cmp pow)' +
'\n\n METHOD CALLS: The number of method calls to be timed' +
'\n\n MAX DIGITS: The maximum number of digits of the random ' +
'\n numbers used in the method calls' +
'\n\n DECIMAL PLACES: The number of decimal places used in division' +
'\n (The rounding mode is randomly chosen)' +
'\n\n Default values: METHOD: randomly chosen' +
'\n METHOD CALLS: ' + DEFAULT_REPS +
' (pow: ' + DEFAULT_POW_REPS + ')' +
'\n MAX DIGITS: ' + DEFAULT_MAX_DIGITS +
' (pow: ' + DEFAULT_POW_MAX_DIGITS + ')' +
'\n DECIMAL PLACES: ' + DEFAULT_PLACES + '\n' +
'\n E.g.s node bigtime-OOM\n node bigtime-OOM minus' +
'\n node bigtime-OOM add 100000' +
'\n node bigtime-OOM times 20000 100' +
'\n node bigtime-OOM div 100000 50 20' +
'\n node bigtime-OOM 9000' +
'\n node bigtime-OOM 1000000 20\n' +
'\n To show memory usage include an argument m or -m' +
'\n E.g. node bigtime-OOM m add');
} else {
BigNumber.config({EXPONENTIAL_AT : 1E9, RANGE : 1E9});
Number.prototype.toPlainString = Number.prototype.toString;
for (i = 0; i < args.length; i++) {
arg = args[i];
if (isFinite(arg)) {
arg = Math.abs(parseInt(arg));
if (reps == null) {
reps = arg <= 1e10 ? arg : 0;
} else if (max == null) {
max = arg <= 1e6 ? arg : 0;
} else if (decimalPlaces == null) {
decimalPlaces = arg <= 1e6 ? arg : DEFAULT_PLACES;
}
} else if (/^-*m$/i.test(arg)) {
showMemory = true;
} else if (method == null) {
method = arg;
}
}
for (i = 0;
i < Ms.length && (methodIndex = Ms[i].indexOf(method)) == -1;
i++) {}
bnM = methodIndex == -1
? bnMs1[methodIndex = Math.floor(Math.random() * bdMs.length)]
: (Ms[i][0] == 'add' ? bnMs1 : Ms[i])[methodIndex];
bdM = bdMs[methodIndex];
if (!reps)
reps = bdM == 'pow' ? DEFAULT_POW_REPS : DEFAULT_REPS;
if (!max)
max = bdM == 'pow' ? DEFAULT_POW_MAX_DIGITS : DEFAULT_MAX_DIGITS;
if (decimalPlaces == null)
decimalPlaces = DEFAULT_PLACES;
Xs = [reps], Ys = [reps];
bdXs = [reps], bdYs = [reps], bdRs = [reps];
bnXs = [reps], bnYs = [reps], bnRs = [reps];
showMemory = showMemory || ALWAYS_SHOW_MEMORY;
console.log('\n BigNumber %s vs BigDecimal %s', bnM, bdM);
console.log('\n Method calls: %d', reps);
if (bdM == 'divide') {
rounding = Math.floor(Math.random() * 7);
console.log('\n Decimal places: %d\n Rounding mode: %d', decimalPlaces, rounding);
BigNumber.config(decimalPlaces, rounding);
}
if (showMemory) {
memoryUsage = process.memoryUsage();
console.log(' Memory usage: rss: ' +
toKB(prevRss = memoryUsage.rss) + ', hU: ' +
toKB(prevHeapUsed = memoryUsage.heapUsed) + ', hT: ' +
toKB(prevHeapTotal = memoryUsage.heapTotal));
}
// CREATE RANDOM NUMBERS
// POW: BigDecimal requires JS Number type for exponent argument
if (bdM == 'pow') {
process.stdout.write('\n Creating ' + reps +
' random numbers (max. digits: ' + max + ')... ');
for (i = 0; i < reps; i++) {
Xs[i] = getRandom(max);
}
console.log('done\n Average number of digits: %d',
((total / reps) | 0));
process.stdout.write(' Creating ' + reps +
' random integer exponents (max. value: ' + MAX_POWER + ')... ');
for (i = 0; i < reps; i++) {
bdYs[i] = bnYs[i] = Math.floor(Math.random() * (MAX_POWER + 1));
expTotal += bdYs[i];
}
console.log('done\n Average value: %d', ((expTotal / reps) | 0));
showMemoryChange();
// POW: TIME CREATION OF BIGDECIMALS
process.stdout.write('\n Creating BigDecimals... ');
start = +new Date();
for (i = 0; i < reps; i++) {
bdXs[i] = new BigDecimal(Xs[i]);
}
bdOT = +new Date() - start;
console.log('done. Time taken: %s ms', bdOT || '<1');
showMemoryChange();
// POW: TIME CREATION OF BIGNUMBERS
process.stdout.write(' Creating BigNumbers... ');
start = +new Date();
for (i = 0; i < reps; i++) {
bnXs[i] = new BigNumber(Xs[i]);
}
bnOT = +new Date() - start;
console.log('done. Time taken: %s ms', bnOT || '<1');
// NOT POW
} else {
process.stdout.write('\n Creating ' + (reps * 2) +
' random numbers (max. digits: ' + max + ')... ');
for (i = 0; i < reps; i++) {
Xs[i] = getRandom(max);
Ys[i] = getRandom(max);
}
console.log('done\n Average number of digits: %d',
( total / (reps * 2) ) | 0);
showMemoryChange();
// TIME CREATION OF BIGDECIMALS
process.stdout.write('\n Creating BigDecimals... ');
start = +new Date();
for (i = 0; i < reps; i++) {
bdXs[i] = new BigDecimal(Xs[i]);
bdYs[i] = new BigDecimal(Ys[i]);
}
bdOT = +new Date() - start;
console.log('done. Time taken: %s ms', bdOT || '<1');
showMemoryChange();
// TIME CREATION OF BIGNUMBERS
process.stdout.write(' Creating BigNumbers... ');
start = +new Date();
for (i = 0; i < reps; i++) {
bnXs[i] = new BigNumber(Xs[i]);
bnYs[i] = new BigNumber(Ys[i]);
}
bnOT = +new Date() - start;
console.log('done. Time taken: %s ms', bnOT || '<1');
}
showMemoryChange();
console.log('\n Object creation: %s\n', getFastest(bnOT, bdOT));
// TIME BIGDECIMAL METHOD CALLS
process.stdout.write(pad(' BigDecimal ' + bdM));
if (bdM == 'divide') {
start = +new Date();
while (i--) bdRs[i] = bdXs[i][bdM](bdYs[i], decimalPlaces, rounding);
bdMT = +new Date() - start;
} else {
start = +new Date();
while (i--) bdRs[i] = bdXs[i][bdM](bdYs[i]);
bdMT = +new Date() - start;
}
console.log('done. Time taken: %s ms', bdMT || '<1');
// TIME BIGNUMBER METHOD CALLS
i = reps;
process.stdout.write(pad(' BigNumber ' + bnM));
start = +new Date();
while (i--) bnRs[i] = bnXs[i][bnM](bnYs[i]);
bnMT = +new Date() - start;
console.log('done. Time taken: %s ms', bnMT || '<1');
// TIMINGS SUMMARY
console.log('\n Method calls: %s', getFastest(bnMT, bdMT));
if (!timesEqual) {
console.log('\n Overall: ' +
getFastest((bnOT || 1) + (bnMT || 1), (bdOT || 1) + (bdMT || 1)));
}
// CHECK FOR MISMATCHES
process.stdout.write('\n Checking for mismatches... ');
for (i = 0; i < reps; i++) {
bnR = bnRs[i].toString();
bdR = bdRs[i].toPlainString();
// Strip any trailing zeros from non-integer BigDecimals
if (bdR.indexOf('.') != -1) {
bdR = bdR.replace(/\.?0+$/, '');
}
if (bdR !== bnR) {
console.log('breaking on first mismatch (result number %d):' +
'\n\n BigDecimal: %s\n BigNumber: %s', i, bdR, bnR);
console.log('\n x: %s\n y: %s', Xs[i], Ys[i]);
if (bdM == 'divide') {
console.log('\n dp: %d\n r: %d',decimalPlaces, rounding);
}
break;
}
}
if (i == reps) {
console.log('done. None found.\n');
}
}

335
perf/bigtime.js Normal file
View File

@ -0,0 +1,335 @@
var arg, i, j, max, method, methodIndex, decimalPlaces, rounding, reps, start,
timesEqual, xs, ys, prevRss, prevHeapUsed, prevHeapTotal, showMemory,
bdM, bdT, bdR, bdRs,
bnM, bnT, bnR, bnRs,
args = process.argv.splice(2),
BigDecimal = require('./lib/bigdecimal_GWT/bigdecimal').BigDecimal,
BigNumber = require('../bignumber'),
bdMs = ['add', 'subtract', 'multiply', 'divide', 'remainder',
'compareTo', 'pow', 'negate', 'abs'],
bnMs1 = ['plus', 'minus', 'times', 'dividedBy', 'modulo',
'comparedTo', 'toPower', 'negated', 'abs'],
bnMs2 = ['', '', '', 'div', 'mod', 'cmp', '', 'neg', ''],
Ms = [bdMs, bnMs1, bnMs2],
allMs = [].concat.apply([], Ms),
bdTotal = 0,
bnTotal = 0,
BD = {},
BN = {},
ALWAYS_SHOW_MEMORY = false,
DEFAULT_MAX_DIGITS = 20,
DEFAULT_POW_MAX_DIGITS = 20,
DEFAULT_REPS = 1e4,
DEFAULT_POW_REPS = 1e2,
DEFAULT_PLACES = 20,
MAX_POWER = 50,
MAX_RANDOM_EXPONENT = 100,
getRandom = function (maxDigits) {
var i = 0, z,
// number of digits - 1
n = Math.random() * ( maxDigits || 1 ) | 0,
r = ( Math.random() * 10 | 0 ) + '';
if ( n ) {
if ( z = r === '0' ) {
r += '.';
}
for ( ; i++ < n; r += Math.random() * 10 | 0 ){}
// 20% chance of integer
if ( !z && Math.random() > 0.2 )
r = r.slice( 0, i = ( Math.random() * n | 0 ) + 1 ) + '.' + r.slice(i);
}
// Avoid 'division by zero' error with division and modulo.
if ((bdM == 'divide' || bdM == 'remainder') && parseFloat(r) === 0)
r = ( ( Math.random() * 9 | 0 ) + 1 ) + '';
// 50% chance of negative
return Math.random() > 0.5 ? r : '-' + r;
},
// Returns exponential notation.
//getRandom = function (maxDigits) {
// var i = 0,
// // n is the number of significant digits - 1
// n = Math.random() * (maxDigits || 1) | 0,
// r = ( ( Math.random() * 9 | 0 ) + 1 ) + ( n ? '.' : '' );
//
// for (; i++ < n; r += Math.random() * 10 | 0 ){}
//
// // Add exponent.
// r += 'e' + ( Math.random() > 0.5 ? '+' : '-' ) +
// ( Math.random() * MAX_RANDOM_EXPONENT | 0 );
//
// // 50% chance of being negative.
// return Math.random() > 0.5 ? r : '-' + r
//},
getFastest = function (bn, bd) {
var r;
if (Math.abs(bn - bd) > 2) {
r = 'Big' + ((bn < bd)
? 'Number was ' + (bn ? parseFloat((bd / bn).toFixed(1)) : bd)
: 'Decimal was ' + (bd ? parseFloat((bn / bd).toFixed(1)) : bn)) +
' times faster';
} else {
timesEqual = 1;
r = 'Times approximately equal';
}
return r;
},
getMemory = function (obj) {
if (showMemory) {
var mem = process.memoryUsage(),
rss = mem.rss,
heapUsed = mem.heapUsed,
heapTotal = mem.heapTotal;
if (obj) {
obj.rss += (rss - prevRss);
obj.hU += (heapUsed - prevHeapUsed);
obj.hT += (heapTotal - prevHeapTotal);
}
prevRss = rss;
prevHeapUsed = heapUsed;
prevHeapTotal = heapTotal;
}
},
getMemoryTotals = function (obj) {
function toKB(m) {return parseFloat((m / 1024).toFixed(1))}
return '\trss: ' + toKB(obj.rss) +
'\thU: ' + toKB(obj.hU) +
'\thT: ' + toKB(obj.hT);
};
if (arg = args[0], typeof arg != 'undefined' && !isFinite(arg) &&
allMs.indexOf(arg) == -1 && !/^-*m$/i.test(arg)) {
console.log(
'\n node bigtime [METHOD] [METHOD CALLS [MAX DIGITS [DECIMAL PLACES]]]\n' +
'\n METHOD: The method to be timed and compared with the' +
'\n \t corresponding method from BigDecimal or BigNumber\n' +
'\n BigDecimal: add subtract multiply divide remainder' +
' compareTo pow\n\t\tnegate abs\n\n BigNumber: plus minus times' +
' dividedBy modulo comparedTo toPower\n\t\tnegated abs' +
' (div mod cmp pow neg)' +
'\n\n METHOD CALLS: The number of method calls to be timed' +
'\n\n MAX DIGITS: The maximum number of digits of the random ' +
'\n\t\tnumbers used in the method calls\n\n ' +
'DECIMAL PLACES: The number of decimal places used in division' +
'\n\t\t(The rounding mode is randomly chosen)' +
'\n\n Default values: METHOD: randomly chosen' +
'\n\t\t METHOD CALLS: ' + DEFAULT_REPS +
' (pow: ' + DEFAULT_POW_REPS + ')' +
'\n\t\t MAX DIGITS: ' + DEFAULT_MAX_DIGITS +
' (pow: ' + DEFAULT_POW_MAX_DIGITS + ')' +
'\n\t\t DECIMAL PLACES: ' + DEFAULT_PLACES + '\n' +
'\n E.g. node bigtime\n\tnode bigtime minus\n\tnode bigtime add 100000' +
'\n\tnode bigtime times 20000 100\n\tnode bigtime div 100000 50 20' +
'\n\tnode bigtime 9000\n\tnode bigtime 1000000 20\n' +
'\n To show memory usage, include an argument m or -m' +
'\n E.g. node bigtime m add');
} else {
BigNumber.config({EXPONENTIAL_AT : 1E9, RANGE : 1E9});
Number.prototype.toPlainString = Number.prototype.toString;
for (i = 0; i < args.length; i++) {
arg = args[i];
if (isFinite(arg)) {
arg = Math.abs(parseInt(arg));
if (reps == null)
reps = arg <= 1e10 ? arg : 0;
else if (max == null)
max = arg <= 1e6 ? arg : 0;
else if (decimalPlaces == null)
decimalPlaces = arg <= 1e6 ? arg : DEFAULT_PLACES;
} else if (/^-*m$/i.test(arg))
showMemory = true;
else if (method == null)
method = arg;
}
for (i = 0;
i < Ms.length && (methodIndex = Ms[i].indexOf(method)) == -1;
i++) {}
bnM = methodIndex == -1
? bnMs1[methodIndex = Math.floor(Math.random() * bdMs.length)]
: (Ms[i][0] == 'add' ? bnMs1 : Ms[i])[methodIndex];
bdM = bdMs[methodIndex];
if (!reps)
reps = bdM == 'pow' ? DEFAULT_POW_REPS : DEFAULT_REPS;
if (!max)
max = bdM == 'pow' ? DEFAULT_POW_MAX_DIGITS : DEFAULT_MAX_DIGITS;
if (decimalPlaces == null)
decimalPlaces = DEFAULT_PLACES;
xs = [reps], ys = [reps], bdRs = [reps], bnRs = [reps];
BD.rss = BD.hU = BD.hT = BN.rss = BN.hU = BN.hT = 0;
showMemory = showMemory || ALWAYS_SHOW_MEMORY;
console.log('\n BigNumber %s vs BigDecimal %s\n' +
'\n Method calls: %d\n\n Random operands: %d', bnM, bdM, reps,
bdM == 'abs' || bdM == 'negate' || bdM == 'abs' ? reps : reps * 2);
console.log(' Max. digits of operands: %d', max);
if (bdM == 'divide') {
rounding = Math.floor(Math.random() * 7);
console.log('\n Decimal places: %d\n Rounding mode: %d', decimalPlaces, rounding);
BigNumber.config(decimalPlaces, rounding);
}
process.stdout.write('\n Testing started');
outer:
for (; reps > 0; reps -= 1e4) {
j = Math.min(reps, 1e4);
// GENERATE RANDOM OPERANDS
for (i = 0; i < j; i++) {
xs[i] = getRandom(max);
}
if (bdM == 'pow') {
for (i = 0; i < j; i++) {
ys[i] = Math.floor(Math.random() * (MAX_POWER + 1));
}
} else if (bdM != 'abs' && bdM != 'negate') {
for (i = 0; i < j; i++) {
ys[i] = getRandom(max);
}
}
getMemory();
// BIGDECIMAL
if (bdM == 'divide') {
start = +new Date();
for (i = 0; i < j; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](new BigDecimal(ys[i]),
decimalPlaces, rounding);
}
bdT = +new Date() - start;
} else if (bdM == 'pow') {
start = +new Date();
for (i = 0; i < j; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](ys[i]);
}
bdT = +new Date() - start;
} else if (bdM == 'abs' || bdM == 'negate') {
start = +new Date();
for (i = 0; i < j; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM]();
}
bdT = +new Date() - start;
} else {
start = +new Date();
for (i = 0; i < j; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](new BigDecimal(ys[i]));
}
bdT = +new Date() - start;
}
getMemory(BD);
// BIGNUMBER
if (bdM == 'pow') {
start = +new Date();
for (i = 0; i < j; i++) {
bnRs[i] = new BigNumber(xs[i])[bnM](ys[i]);
}
bnT = +new Date() - start;
} else if (bdM == 'abs' || bdM == 'negate') {
start = +new Date();
for (i = 0; i < j; i++) {
bnRs[i] = new BigNumber(xs[i])[bnM]();
}
bnT = +new Date() - start;
} else {
start = +new Date();
for (i = 0; i < j; i++) {
bnRs[i] = new BigNumber(xs[i])[bnM](new BigNumber(ys[i]));
}
bnT = +new Date() - start;
}
getMemory(BN);
// CHECK FOR MISMATCHES
for (i = 0; i < j; i++) {
bnR = bnRs[i].toString();
bdR = bdRs[i].toPlainString();
// Strip any trailing zeros from non-integer BigDecimals
if (bdR.indexOf('.') != -1) {
bdR = bdR.replace(/\.?0+$/, '');
}
if (bdR !== bnR) {
console.log('\n breaking on first mismatch (result number %d):' +
'\n\n BigDecimal: %s\n BigNumber: %s', i, bdR, bnR);
console.log('\n x: %s\n y: %s', xs[i], ys[i]);
if (bdM == 'divide')
console.log('\n dp: %d\n r: %d',decimalPlaces, rounding);
break outer;
}
}
bdTotal += bdT;
bnTotal += bnT;
process.stdout.write(' .');
}
// TIMINGS SUMMARY
if (i == j) {
console.log(' done\n\n No mismatches.');
if (showMemory) {
console.log('\n Change in memory usage (KB):' +
'\n\tBigDecimal' + getMemoryTotals(BD) +
'\n\tBigNumber ' + getMemoryTotals(BN));
}
console.log('\n Time taken:' +
'\n\tBigDecimal ' + (bdTotal || '<1') + ' ms' +
'\n\tBigNumber ' + (bnTotal || '<1') + ' ms\n\n ' +
getFastest(bnTotal, bdTotal) + '\n');
}
}

Binary file not shown.

View File

@ -0,0 +1,60 @@
// javac BigDecTest.java
// java BigDecTest
import java.math.BigDecimal;
public class BigDecTest
{
public static void main(String[] args) {
int i;
BigDecimal x, y, r;
// remainder
x = new BigDecimal("9.785496E-2");
y = new BigDecimal("-5.9219189762E-2");
r = x.remainder(y);
System.out.println( r.toString() );
// 0.038635770238
x = new BigDecimal("1.23693014661017964112E-5");
y = new BigDecimal("-6.9318042E-7");
r = x.remainder(y);
System.out.println( r.toPlainString() );
// 0.0000005852343261017964112
// divide
x = new BigDecimal("6.9609119610E-78");
y = new BigDecimal("4E-48");
r = x.divide(y, 40, 6); // ROUND_HALF_EVEN
System.out.println( r.toString() );
// 1.7402279902E-30
x = new BigDecimal("5.383458817E-83");
y = new BigDecimal("8E-54");
r = x.divide(y, 40, 6);
System.out.println( r.toString() );
// 6.7293235212E-30
// compareTo
x = new BigDecimal("0.04");
y = new BigDecimal("0.079393068");
i = x.compareTo(y);
System.out.println(i);
// -1
x = new BigDecimal("7.88749578569876987785987658649E-10");
y = new BigDecimal("4.2545098709E-6");
i = x.compareTo(y);
System.out.println(i);
// -1
}
}

View File

@ -0,0 +1,205 @@
https://github.com/iriscouch/bigdecimal.js
BigDecimal for Javascript is licensed under the Apache License, version 2.0:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,53 @@
// node bugs
// Compare with BigDecTest.java
var i, x, y, r,
BigDecimal = require('./bigdecimal').BigDecimal;
// remainder
x = new BigDecimal("9.785496E-2");
y = new BigDecimal("-5.9219189762E-2");
r = x.remainder(y);
console.log( r.toString() );
// 0.09785496
// Should be 0.038635770238
x = new BigDecimal("1.23693014661017964112E-5");
y = new BigDecimal("-6.9318042E-7");
r = x.remainder(y);
console.log( r.toPlainString() );
// 0.0000123693014661017964112
// Should be 0.0000005852343261017964112
// divide
x = new BigDecimal("6.9609119610E-78");
y = new BigDecimal("4E-48");
r = x.divide(y, 40, 6); // ROUND_HALF_EVEN
console.log( r.toString() );
// 1.7402279903E-30
// Should be 1.7402279902E-30
x = new BigDecimal("5.383458817E-83");
y = new BigDecimal("8E-54");
r = x.divide(y, 40, 6);
console.log( r.toString() );
// 6.7293235213E-30
// Should be 6.7293235212E-30
// compareTo
x = new BigDecimal("0.04");
y = new BigDecimal("0.079393068");
i = x.compareTo(y);
console.log(i);
// 1
// Should be -1
x = new BigDecimal("7.88749578569876987785987658649E-10");
y = new BigDecimal("4.2545098709E-6");
i = x.compareTo(y);
console.log(i);
// 1
// Should be -1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
/*
Copyright (c) 2012 Daniel Trebbien and other contributors
Portions Copyright (c) 2003 STZ-IDA and PTV AG, Karlsruhe, Germany
Portions Copyright (c) 1995-2001 International Business Machines Corporation and others
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
*/
(function(){var m,k=function(){this.form=this.digits=0;this.lostDigits=!1;this.roundingMode=0;var a=this.DEFAULT_FORM,b=this.DEFAULT_LOSTDIGITS,c=this.DEFAULT_ROUNDINGMODE;if(4==k.arguments.length)a=k.arguments[1],b=k.arguments[2],c=k.arguments[3];else if(3==k.arguments.length)a=k.arguments[1],b=k.arguments[2];else if(2==k.arguments.length)a=k.arguments[1];else if(1!=k.arguments.length)throw"MathContext(): "+k.arguments.length+" arguments given; expected 1 to 4";var d=k.arguments[0];if(d!=this.DEFAULT_DIGITS){if(d<
this.MIN_DIGITS)throw"MathContext(): Digits too small: "+d;if(d>this.MAX_DIGITS)throw"MathContext(): Digits too large: "+d;}if(a!=this.SCIENTIFIC&&a!=this.ENGINEERING&&a!=this.PLAIN)throw"MathContext() Bad form value: "+a;if(!this.isValidRound(c))throw"MathContext(): Bad roundingMode value: "+c;this.digits=d;this.form=a;this.lostDigits=b;this.roundingMode=c};k.prototype.getDigits=function(){return this.digits};k.prototype.getForm=function(){return this.form};k.prototype.getLostDigits=function(){return this.lostDigits};
k.prototype.getRoundingMode=function(){return this.roundingMode};k.prototype.toString=function(){var a=null,b=0,c=null,a=this.form==this.SCIENTIFIC?"SCIENTIFIC":this.form==this.ENGINEERING?"ENGINEERING":"PLAIN",d=this.ROUNDS.length,b=0;a:for(;0<d;d--,b++)if(this.roundingMode==this.ROUNDS[b]){c=this.ROUNDWORDS[b];break a}return"digits="+this.digits+" form="+a+" lostDigits="+(this.lostDigits?"1":"0")+" roundingMode="+c};k.prototype.isValidRound=function(a){var b=0,c=this.ROUNDS.length,b=0;for(;0<c;c--,
b++)if(a==this.ROUNDS[b])return!0;return!1};k.PLAIN=k.prototype.PLAIN=0;k.SCIENTIFIC=k.prototype.SCIENTIFIC=1;k.ENGINEERING=k.prototype.ENGINEERING=2;k.ROUND_CEILING=k.prototype.ROUND_CEILING=2;k.ROUND_DOWN=k.prototype.ROUND_DOWN=1;k.ROUND_FLOOR=k.prototype.ROUND_FLOOR=3;k.ROUND_HALF_DOWN=k.prototype.ROUND_HALF_DOWN=5;k.ROUND_HALF_EVEN=k.prototype.ROUND_HALF_EVEN=6;k.ROUND_HALF_UP=k.prototype.ROUND_HALF_UP=4;k.ROUND_UNNECESSARY=k.prototype.ROUND_UNNECESSARY=7;k.ROUND_UP=k.prototype.ROUND_UP=0;k.prototype.DEFAULT_FORM=
k.prototype.SCIENTIFIC;k.prototype.DEFAULT_DIGITS=9;k.prototype.DEFAULT_LOSTDIGITS=!1;k.prototype.DEFAULT_ROUNDINGMODE=k.prototype.ROUND_HALF_UP;k.prototype.MIN_DIGITS=0;k.prototype.MAX_DIGITS=999999999;k.prototype.ROUNDS=[k.prototype.ROUND_HALF_UP,k.prototype.ROUND_UNNECESSARY,k.prototype.ROUND_CEILING,k.prototype.ROUND_DOWN,k.prototype.ROUND_FLOOR,k.prototype.ROUND_HALF_DOWN,k.prototype.ROUND_HALF_EVEN,k.prototype.ROUND_UP];k.prototype.ROUNDWORDS="ROUND_HALF_UP ROUND_UNNECESSARY ROUND_CEILING ROUND_DOWN ROUND_FLOOR ROUND_HALF_DOWN ROUND_HALF_EVEN ROUND_UP".split(" ");
k.prototype.DEFAULT=new k(k.prototype.DEFAULT_DIGITS,k.prototype.DEFAULT_FORM,k.prototype.DEFAULT_LOSTDIGITS,k.prototype.DEFAULT_ROUNDINGMODE);m=k;var v,G=function(a,b){return(a-a%b)/b},K=function(a){var b=Array(a),c;for(c=0;c<a;++c)b[c]=0;return b},h=function(){this.ind=0;this.form=m.prototype.PLAIN;this.mant=null;this.exp=0;if(0!=h.arguments.length){var a,b,c;1==h.arguments.length?(a=h.arguments[0],b=0,c=a.length):(a=h.arguments[0],b=h.arguments[1],c=h.arguments[2]);"string"==typeof a&&(a=a.split(""));
var d,e,i,f,g,j=0,l=0;e=!1;var k=l=l=j=0,q=0;f=0;0>=c&&this.bad("BigDecimal(): ",a);this.ind=this.ispos;"-"==a[0]?(c--,0==c&&this.bad("BigDecimal(): ",a),this.ind=this.isneg,b++):"+"==a[0]&&(c--,0==c&&this.bad("BigDecimal(): ",a),b++);e=d=!1;i=0;g=f=-1;k=c;j=b;a:for(;0<k;k--,j++){l=a[j];if("0"<=l&&"9">=l){g=j;i++;continue a}if("."==l){0<=f&&this.bad("BigDecimal(): ",a);f=j-b;continue a}if("e"!=l&&"E"!=l){("0">l||"9"<l)&&this.bad("BigDecimal(): ",a);d=!0;g=j;i++;continue a}j-b>c-2&&this.bad("BigDecimal(): ",
a);e=!1;"-"==a[j+1]?(e=!0,j+=2):j="+"==a[j+1]?j+2:j+1;l=c-(j-b);(0==l||9<l)&&this.bad("BigDecimal(): ",a);c=l;l=j;for(;0<c;c--,l++)k=a[l],"0">k&&this.bad("BigDecimal(): ",a),"9"<k?this.bad("BigDecimal(): ",a):q=k-0,this.exp=10*this.exp+q;e&&(this.exp=-this.exp);e=!0;break a}0==i&&this.bad("BigDecimal(): ",a);0<=f&&(this.exp=this.exp+f-i);q=g-1;j=b;a:for(;j<=q;j++)if(l=a[j],"0"==l)b++,f--,i--;else if("."==l)b++,f--;else break a;this.mant=Array(i);l=b;if(d){b=i;j=0;for(;0<b;b--,j++)j==f&&l++,k=a[l],
"9">=k?this.mant[j]=k-0:this.bad("BigDecimal(): ",a),l++}else{b=i;j=0;for(;0<b;b--,j++)j==f&&l++,this.mant[j]=a[l]-0,l++}0==this.mant[0]?(this.ind=this.iszero,0<this.exp&&(this.exp=0),e&&(this.mant=this.ZERO.mant,this.exp=0)):e&&(this.form=m.prototype.SCIENTIFIC,f=this.exp+this.mant.length-1,(f<this.MinExp||f>this.MaxExp)&&this.bad("BigDecimal(): ",a))}},H=function(){var a;if(1==H.arguments.length)a=H.arguments[0];else if(0==H.arguments.length)a=this.plainMC;else throw"abs(): "+H.arguments.length+
" arguments given; expected 0 or 1";return this.ind==this.isneg?this.negate(a):this.plus(a)},w=function(){var a;if(2==w.arguments.length)a=w.arguments[1];else if(1==w.arguments.length)a=this.plainMC;else throw"add(): "+w.arguments.length+" arguments given; expected 1 or 2";var b=w.arguments[0],c,d,e,i,f,g,j,l=0;d=l=0;var l=null,k=l=0,q=0,t=0,s=0,n=0;a.lostDigits&&this.checkdigits(b,a.digits);c=this;if(0==c.ind&&a.form!=m.prototype.PLAIN)return b.plus(a);if(0==b.ind&&a.form!=m.prototype.PLAIN)return c.plus(a);
d=a.digits;0<d&&(c.mant.length>d&&(c=this.clone(c).round(a)),b.mant.length>d&&(b=this.clone(b).round(a)));e=new h;i=c.mant;f=c.mant.length;g=b.mant;j=b.mant.length;if(c.exp==b.exp)e.exp=c.exp;else if(c.exp>b.exp){l=f+c.exp-b.exp;if(l>=j+d+1&&0<d)return e.mant=i,e.exp=c.exp,e.ind=c.ind,f<d&&(e.mant=this.extend(c.mant,d),e.exp-=d-f),e.finish(a,!1);e.exp=b.exp;l>d+1&&0<d&&(l=l-d-1,j-=l,e.exp+=l,l=d+1);l>f&&(f=l)}else{l=j+b.exp-c.exp;if(l>=f+d+1&&0<d)return e.mant=g,e.exp=b.exp,e.ind=b.ind,j<d&&(e.mant=
this.extend(b.mant,d),e.exp-=d-j),e.finish(a,!1);e.exp=c.exp;l>d+1&&0<d&&(l=l-d-1,f-=l,e.exp+=l,l=d+1);l>j&&(j=l)}e.ind=c.ind==this.iszero?this.ispos:c.ind;if((c.ind==this.isneg?1:0)==(b.ind==this.isneg?1:0))d=1;else{do{d=-1;do if(b.ind!=this.iszero)if(f<j||c.ind==this.iszero)l=i,i=g,g=l,l=f,f=j,j=l,e.ind=-e.ind;else if(!(f>j)){k=l=0;q=i.length-1;t=g.length-1;c:for(;;){if(l<=q)s=i[l];else{if(k>t){if(a.form!=m.prototype.PLAIN)return this.ZERO;break c}s=0}n=k<=t?g[k]:0;if(s!=n){s<n&&(l=i,i=g,g=l,l=
f,f=j,j=l,e.ind=-e.ind);break c}l++;k++}}while(0)}while(0)}e.mant=this.byteaddsub(i,f,g,j,d,!1);return e.finish(a,!1)},x=function(){var a;if(2==x.arguments.length)a=x.arguments[1];else if(1==x.arguments.length)a=this.plainMC;else throw"compareTo(): "+x.arguments.length+" arguments given; expected 1 or 2";var b=x.arguments[0],c=0,c=0;a.lostDigits&&this.checkdigits(b,a.digits);if(this.ind==b.ind&&this.exp==b.exp){c=this.mant.length;if(c<b.mant.length)return-this.ind;if(c>b.mant.length)return this.ind;
if(c<=a.digits||0==a.digits){a=c;c=0;for(;0<a;a--,c++){if(this.mant[c]<b.mant[c])return-this.ind;if(this.mant[c]>b.mant[c])return this.ind}return 0}}else{if(this.ind<b.ind)return-1;if(this.ind>b.ind)return 1}b=this.clone(b);b.ind=-b.ind;return this.add(b,a).ind},p=function(){var a,b=-1;if(2==p.arguments.length)a="number"==typeof p.arguments[1]?new m(0,m.prototype.PLAIN,!1,p.arguments[1]):p.arguments[1];else if(3==p.arguments.length){b=p.arguments[1];if(0>b)throw"divide(): Negative scale: "+b;a=new m(0,
m.prototype.PLAIN,!1,p.arguments[2])}else if(1==p.arguments.length)a=this.plainMC;else throw"divide(): "+p.arguments.length+" arguments given; expected between 1 and 3";return this.dodivide("D",p.arguments[0],a,b)},y=function(){var a;if(2==y.arguments.length)a=y.arguments[1];else if(1==y.arguments.length)a=this.plainMC;else throw"divideInteger(): "+y.arguments.length+" arguments given; expected 1 or 2";return this.dodivide("I",y.arguments[0],a,0)},z=function(){var a;if(2==z.arguments.length)a=z.arguments[1];
else if(1==z.arguments.length)a=this.plainMC;else throw"max(): "+z.arguments.length+" arguments given; expected 1 or 2";var b=z.arguments[0];return 0<=this.compareTo(b,a)?this.plus(a):b.plus(a)},A=function(){var a;if(2==A.arguments.length)a=A.arguments[1];else if(1==A.arguments.length)a=this.plainMC;else throw"min(): "+A.arguments.length+" arguments given; expected 1 or 2";var b=A.arguments[0];return 0>=this.compareTo(b,a)?this.plus(a):b.plus(a)},B=function(){var a;if(2==B.arguments.length)a=B.arguments[1];
else if(1==B.arguments.length)a=this.plainMC;else throw"multiply(): "+B.arguments.length+" arguments given; expected 1 or 2";var b=B.arguments[0],c,d,e,i=e=null,f,g=0,j,l=0,k=0;a.lostDigits&&this.checkdigits(b,a.digits);c=this;d=0;e=a.digits;0<e?(c.mant.length>e&&(c=this.clone(c).round(a)),b.mant.length>e&&(b=this.clone(b).round(a))):(0<c.exp&&(d+=c.exp),0<b.exp&&(d+=b.exp));c.mant.length<b.mant.length?(e=c.mant,i=b.mant):(e=b.mant,i=c.mant);f=e.length+i.length-1;g=9<e[0]*i[0]?f+1:f;j=new h;var g=
this.createArrayWithZeros(g),m=e.length,l=0;for(;0<m;m--,l++)k=e[l],0!=k&&(g=this.byteaddsub(g,g.length,i,f,k,!0)),f--;j.ind=c.ind*b.ind;j.exp=c.exp+b.exp-d;j.mant=0==d?g:this.extend(g,g.length+d);return j.finish(a,!1)},I=function(){var a;if(1==I.arguments.length)a=I.arguments[0];else if(0==I.arguments.length)a=this.plainMC;else throw"negate(): "+I.arguments.length+" arguments given; expected 0 or 1";var b;a.lostDigits&&this.checkdigits(null,a.digits);b=this.clone(this);b.ind=-b.ind;return b.finish(a,
!1)},J=function(){var a;if(1==J.arguments.length)a=J.arguments[0];else if(0==J.arguments.length)a=this.plainMC;else throw"plus(): "+J.arguments.length+" arguments given; expected 0 or 1";a.lostDigits&&this.checkdigits(null,a.digits);return a.form==m.prototype.PLAIN&&this.form==m.prototype.PLAIN&&(this.mant.length<=a.digits||0==a.digits)?this:this.clone(this).finish(a,!1)},C=function(){var a;if(2==C.arguments.length)a=C.arguments[1];else if(1==C.arguments.length)a=this.plainMC;else throw"pow(): "+
C.arguments.length+" arguments given; expected 1 or 2";var b=C.arguments[0],c,d,e,i=e=0,f,g=0;a.lostDigits&&this.checkdigits(b,a.digits);c=b.intcheck(this.MinArg,this.MaxArg);d=this;e=a.digits;if(0==e){if(b.ind==this.isneg)throw"pow(): Negative power: "+b.toString();e=0}else{if(b.mant.length+b.exp>e)throw"pow(): Too many digits: "+b.toString();d.mant.length>e&&(d=this.clone(d).round(a));i=b.mant.length+b.exp;e=e+i+1}e=new m(e,a.form,!1,a.roundingMode);i=this.ONE;if(0==c)return i;0>c&&(c=-c);f=!1;
g=1;a:for(;;g++){c<<=1;0>c&&(f=!0,i=i.multiply(d,e));if(31==g)break a;if(!f)continue a;i=i.multiply(i,e)}0>b.ind&&(i=this.ONE.divide(i,e));return i.finish(a,!0)},D=function(){var a;if(2==D.arguments.length)a=D.arguments[1];else if(1==D.arguments.length)a=this.plainMC;else throw"remainder(): "+D.arguments.length+" arguments given; expected 1 or 2";return this.dodivide("R",D.arguments[0],a,-1)},E=function(){var a;if(2==E.arguments.length)a=E.arguments[1];else if(1==E.arguments.length)a=this.plainMC;
else throw"subtract(): "+E.arguments.length+" arguments given; expected 1 or 2";var b=E.arguments[0];a.lostDigits&&this.checkdigits(b,a.digits);b=this.clone(b);b.ind=-b.ind;return this.add(b,a)},r=function(){var a,b,c,d;if(6==r.arguments.length)a=r.arguments[2],b=r.arguments[3],c=r.arguments[4],d=r.arguments[5];else if(2==r.arguments.length)b=a=-1,c=m.prototype.SCIENTIFIC,d=this.ROUND_HALF_UP;else throw"format(): "+r.arguments.length+" arguments given; expected 2 or 6";var e=r.arguments[0],i=r.arguments[1],
f,g=0,g=g=0,j=null,l=j=g=0;f=0;g=null;l=j=0;(-1>e||0==e)&&this.badarg("format",1,e);-1>i&&this.badarg("format",2,i);(-1>a||0==a)&&this.badarg("format",3,a);-1>b&&this.badarg("format",4,b);c!=m.prototype.SCIENTIFIC&&c!=m.prototype.ENGINEERING&&(-1==c?c=m.prototype.SCIENTIFIC:this.badarg("format",5,c));if(d!=this.ROUND_HALF_UP)try{-1==d?d=this.ROUND_HALF_UP:new m(9,m.prototype.SCIENTIFIC,!1,d)}catch(h){this.badarg("format",6,d)}f=this.clone(this);-1==b?f.form=m.prototype.PLAIN:f.ind==this.iszero?f.form=
m.prototype.PLAIN:(g=f.exp+f.mant.length,f.form=g>b?c:-5>g?c:m.prototype.PLAIN);if(0<=i)a:for(;;){f.form==m.prototype.PLAIN?g=-f.exp:f.form==m.prototype.SCIENTIFIC?g=f.mant.length-1:(g=(f.exp+f.mant.length-1)%3,0>g&&(g=3+g),g++,g=g>=f.mant.length?0:f.mant.length-g);if(g==i)break a;if(g<i){j=this.extend(f.mant,f.mant.length+i-g);f.mant=j;f.exp-=i-g;if(f.exp<this.MinExp)throw"format(): Exponent Overflow: "+f.exp;break a}g-=i;if(g>f.mant.length){f.mant=this.ZERO.mant;f.ind=this.iszero;f.exp=0;continue a}j=
f.mant.length-g;l=f.exp;f.round(j,d);if(f.exp-l==g)break a}b=f.layout();if(0<e){c=b.length;f=0;a:for(;0<c;c--,f++){if("."==b[f])break a;if("E"==b[f])break a}f>e&&this.badarg("format",1,e);if(f<e){g=Array(b.length+e-f);e-=f;j=0;for(;0<e;e--,j++)g[j]=" ";this.arraycopy(b,0,g,j,b.length);b=g}}if(0<a){e=b.length-1;f=b.length-1;a:for(;0<e;e--,f--)if("E"==b[f])break a;if(0==f){g=Array(b.length+a+2);this.arraycopy(b,0,g,0,b.length);a+=2;j=b.length;for(;0<a;a--,j++)g[j]=" ";b=g}else if(l=b.length-f-2,l>a&&
this.badarg("format",3,a),l<a){g=Array(b.length+a-l);this.arraycopy(b,0,g,0,f+2);a-=l;j=f+2;for(;0<a;a--,j++)g[j]="0";this.arraycopy(b,f+2,g,j,l);b=g}}return b.join("")},F=function(){var a;if(2==F.arguments.length)a=F.arguments[1];else if(1==F.arguments.length)a=this.ROUND_UNNECESSARY;else throw"setScale(): "+F.arguments.length+" given; expected 1 or 2";var b=F.arguments[0],c,d;c=c=0;c=this.scale();if(c==b&&this.form==m.prototype.PLAIN)return this;d=this.clone(this);if(c<=b)c=0==c?d.exp+b:b-c,d.mant=
this.extend(d.mant,d.mant.length+c),d.exp=-b;else{if(0>b)throw"setScale(): Negative scale: "+b;c=d.mant.length-(c-b);d=d.round(c,a);d.exp!=-b&&(d.mant=this.extend(d.mant,d.mant.length+1),d.exp-=1)}d.form=m.prototype.PLAIN;return d};v=function(){var a,b=0,c=0;a=Array(190);b=0;a:for(;189>=b;b++){c=b-90;if(0<=c){a[b]=c%10;h.prototype.bytecar[b]=G(c,10);continue a}c+=100;a[b]=c%10;h.prototype.bytecar[b]=G(c,10)-10}return a};var u=function(){var a,b;if(2==u.arguments.length)a=u.arguments[0],b=u.arguments[1];
else if(1==u.arguments.length)b=u.arguments[0],a=b.digits,b=b.roundingMode;else throw"round(): "+u.arguments.length+" arguments given; expected 1 or 2";var c,d,e=!1,i=0,f;c=null;c=this.mant.length-a;if(0>=c)return this;this.exp+=c;c=this.ind;d=this.mant;0<a?(this.mant=Array(a),this.arraycopy(d,0,this.mant,0,a),e=!0,i=d[a]):(this.mant=this.ZERO.mant,this.ind=this.iszero,e=!1,i=0==a?d[0]:0);f=0;if(b==this.ROUND_HALF_UP)5<=i&&(f=c);else if(b==this.ROUND_UNNECESSARY){if(!this.allzero(d,a))throw"round(): Rounding necessary";
}else if(b==this.ROUND_HALF_DOWN)5<i?f=c:5==i&&(this.allzero(d,a+1)||(f=c));else if(b==this.ROUND_HALF_EVEN)5<i?f=c:5==i&&(this.allzero(d,a+1)?1==this.mant[this.mant.length-1]%2&&(f=c):f=c);else if(b!=this.ROUND_DOWN)if(b==this.ROUND_UP)this.allzero(d,a)||(f=c);else if(b==this.ROUND_CEILING)0<c&&(this.allzero(d,a)||(f=c));else if(b==this.ROUND_FLOOR)0>c&&(this.allzero(d,a)||(f=c));else throw"round(): Bad round value: "+b;0!=f&&(this.ind==this.iszero?(this.mant=this.ONE.mant,this.ind=f):(this.ind==
this.isneg&&(f=-f),c=this.byteaddsub(this.mant,this.mant.length,this.ONE.mant,1,f,e),c.length>this.mant.length?(this.exp++,this.arraycopy(c,0,this.mant,0,this.mant.length)):this.mant=c));if(this.exp>this.MaxExp)throw"round(): Exponent Overflow: "+this.exp;return this};h.prototype.div=G;h.prototype.arraycopy=function(a,b,c,d,e){var i;if(d>b)for(i=e-1;0<=i;--i)c[i+d]=a[i+b];else for(i=0;i<e;++i)c[i+d]=a[i+b]};h.prototype.createArrayWithZeros=K;h.prototype.abs=H;h.prototype.add=w;h.prototype.compareTo=
x;h.prototype.divide=p;h.prototype.divideInteger=y;h.prototype.max=z;h.prototype.min=A;h.prototype.multiply=B;h.prototype.negate=I;h.prototype.plus=J;h.prototype.pow=C;h.prototype.remainder=D;h.prototype.subtract=E;h.prototype.equals=function(a){var b=0,c=null,d=null;if(null==a||!(a instanceof h)||this.ind!=a.ind)return!1;if(this.mant.length==a.mant.length&&this.exp==a.exp&&this.form==a.form){c=this.mant.length;b=0;for(;0<c;c--,b++)if(this.mant[b]!=a.mant[b])return!1}else{c=this.layout();d=a.layout();
if(c.length!=d.length)return!1;a=c.length;b=0;for(;0<a;a--,b++)if(c[b]!=d[b])return!1}return!0};h.prototype.format=r;h.prototype.intValueExact=function(){var a,b=0,c,d=0;a=0;if(this.ind==this.iszero)return 0;a=this.mant.length-1;if(0>this.exp){a+=this.exp;if(!this.allzero(this.mant,a+1))throw"intValueExact(): Decimal part non-zero: "+this.toString();if(0>a)return 0;b=0}else{if(9<this.exp+a)throw"intValueExact(): Conversion overflow: "+this.toString();b=this.exp}c=0;var e=a+b,d=0;for(;d<=e;d++)c*=
10,d<=a&&(c+=this.mant[d]);if(9==a+b&&(a=G(c,1E9),a!=this.mant[0])){if(-2147483648==c&&this.ind==this.isneg&&2==this.mant[0])return c;throw"intValueExact(): Conversion overflow: "+this.toString();}return this.ind==this.ispos?c:-c};h.prototype.movePointLeft=function(a){var b;b=this.clone(this);b.exp-=a;return b.finish(this.plainMC,!1)};h.prototype.movePointRight=function(a){var b;b=this.clone(this);b.exp+=a;return b.finish(this.plainMC,!1)};h.prototype.scale=function(){return 0<=this.exp?0:-this.exp};
h.prototype.setScale=F;h.prototype.signum=function(){return this.ind};h.prototype.toString=function(){return this.layout().join("")};h.prototype.layout=function(){var a,b=0,b=null,c=0,d=0;a=0;var d=null,e,b=0;a=Array(this.mant.length);c=this.mant.length;b=0;for(;0<c;c--,b++)a[b]=this.mant[b]+"";if(this.form!=m.prototype.PLAIN){b="";this.ind==this.isneg&&(b+="-");c=this.exp+a.length-1;if(this.form==m.prototype.SCIENTIFIC)b+=a[0],1<a.length&&(b+="."),b+=a.slice(1).join("");else if(d=c%3,0>d&&(d=3+d),
c-=d,d++,d>=a.length){b+=a.join("");for(a=d-a.length;0<a;a--)b+="0"}else b+=a.slice(0,d).join(""),b=b+"."+a.slice(d).join("");0!=c&&(0>c?(a="-",c=-c):a="+",b+="E",b+=a,b+=c);return b.split("")}if(0==this.exp){if(0<=this.ind)return a;d=Array(a.length+1);d[0]="-";this.arraycopy(a,0,d,1,a.length);return d}c=this.ind==this.isneg?1:0;e=this.exp+a.length;if(1>e){b=c+2-this.exp;d=Array(b);0!=c&&(d[0]="-");d[c]="0";d[c+1]=".";var i=-e,b=c+2;for(;0<i;i--,b++)d[b]="0";this.arraycopy(a,0,d,c+2-e,a.length);return d}if(e>
a.length){d=Array(c+e);0!=c&&(d[0]="-");this.arraycopy(a,0,d,c,a.length);e-=a.length;b=c+a.length;for(;0<e;e--,b++)d[b]="0";return d}b=c+1+a.length;d=Array(b);0!=c&&(d[0]="-");this.arraycopy(a,0,d,c,e);d[c+e]=".";this.arraycopy(a,e,d,c+e+1,a.length-e);return d};h.prototype.intcheck=function(a,b){var c;c=this.intValueExact();if(c<a||c>b)throw"intcheck(): Conversion overflow: "+c;return c};h.prototype.dodivide=function(a,b,c,d){var e,i,f,g,j,l,k,q,t,s=0,n=0,p=0;i=i=n=n=n=0;e=null;e=e=0;e=null;c.lostDigits&&
this.checkdigits(b,c.digits);e=this;if(0==b.ind)throw"dodivide(): Divide by 0";if(0==e.ind)return c.form!=m.prototype.PLAIN?this.ZERO:-1==d?e:e.setScale(d);i=c.digits;0<i?(e.mant.length>i&&(e=this.clone(e).round(c)),b.mant.length>i&&(b=this.clone(b).round(c))):(-1==d&&(d=e.scale()),i=e.mant.length,d!=-e.exp&&(i=i+d+e.exp),i=i-(b.mant.length-1)-b.exp,i<e.mant.length&&(i=e.mant.length),i<b.mant.length&&(i=b.mant.length));f=e.exp-b.exp+e.mant.length-b.mant.length;if(0>f&&"D"!=a)return"I"==a?this.ZERO:
this.clone(e).finish(c,!1);g=new h;g.ind=e.ind*b.ind;g.exp=f;g.mant=this.createArrayWithZeros(i+1);j=i+i+1;f=this.extend(e.mant,j);l=j;k=b.mant;q=j;t=10*k[0]+1;1<k.length&&(t+=k[1]);j=0;a:for(;;){s=0;b:for(;;){if(l<q)break b;if(l==q){c:do{var r=l,n=0;for(;0<r;r--,n++){p=n<k.length?k[n]:0;if(f[n]<p)break b;if(f[n]>p)break c}s++;g.mant[j]=s;j++;f[0]=0;break a}while(0);n=f[0]}else n=10*f[0],1<l&&(n+=f[1]);n=G(10*n,t);0==n&&(n=1);s+=n;f=this.byteaddsub(f,l,k,q,-n,!0);if(0!=f[0])continue b;p=l-2;n=0;c:for(;n<=
p;n++){if(0!=f[n])break c;l--}if(0==n)continue b;this.arraycopy(f,n,f,0,l)}if(0!=j||0!=s){g.mant[j]=s;j++;if(j==i+1)break a;if(0==f[0])break a}if(0<=d&&-g.exp>d)break a;if("D"!=a&&0>=g.exp)break a;g.exp-=1;q--}0==j&&(j=1);if("I"==a||"R"==a){if(j+g.exp>i)throw"dodivide(): Integer overflow";if("R"==a){do{if(0==g.mant[0])return this.clone(e).finish(c,!1);if(0==f[0])return this.ZERO;g.ind=e.ind;i=i+i+1-e.mant.length;g.exp=g.exp-i+e.exp;i=l;n=i-1;b:for(;1<=n&&g.exp<e.exp&&g.exp<b.exp;n--){if(0!=f[n])break b;
i--;g.exp+=1}i<f.length&&(e=Array(i),this.arraycopy(f,0,e,0,i),f=e);g.mant=f;return g.finish(c,!1)}while(0)}}else 0!=f[0]&&(e=g.mant[j-1],0==e%5&&(g.mant[j-1]=e+1));if(0<=d)return j!=g.mant.length&&(g.exp-=g.mant.length-j),e=g.mant.length-(-g.exp-d),g.round(e,c.roundingMode),g.exp!=-d&&(g.mant=this.extend(g.mant,g.mant.length+1),g.exp-=1),g.finish(c,!0);if(j==g.mant.length)g.round(c);else{if(0==g.mant[0])return this.ZERO;e=Array(j);this.arraycopy(g.mant,0,e,0,j);g.mant=e}return g.finish(c,!0)};h.prototype.bad=
function(a,b){throw a+"Not a number: "+b;};h.prototype.badarg=function(a,b,c){throw"Bad argument "+b+" to "+a+": "+c;};h.prototype.extend=function(a,b){var c;if(a.length==b)return a;c=K(b);this.arraycopy(a,0,c,0,a.length);return c};h.prototype.byteaddsub=function(a,b,c,d,e,i){var f,g,j,h,k,m,p=0;f=m=0;f=a.length;g=c.length;b-=1;h=j=d-1;h<b&&(h=b);d=null;i&&h+1==f&&(d=a);null==d&&(d=this.createArrayWithZeros(h+1));k=!1;1==e?k=!0:-1==e&&(k=!0);m=0;p=h;a:for(;0<=p;p--){0<=b&&(b<f&&(m+=a[b]),b--);0<=
j&&(j<g&&(m=k?0<e?m+c[j]:m-c[j]:m+c[j]*e),j--);if(10>m&&0<=m){do{d[p]=m;m=0;continue a}while(0)}m+=90;d[p]=this.bytedig[m];m=this.bytecar[m]}if(0==m)return d;c=null;i&&h+2==a.length&&(c=a);null==c&&(c=Array(h+2));c[0]=m;a=h+1;f=0;for(;0<a;a--,f++)c[f+1]=d[f];return c};h.prototype.diginit=v;h.prototype.clone=function(a){var b;b=new h;b.ind=a.ind;b.exp=a.exp;b.form=a.form;b.mant=a.mant;return b};h.prototype.checkdigits=function(a,b){if(0!=b){if(this.mant.length>b&&!this.allzero(this.mant,b))throw"Too many digits: "+
this.toString();if(null!=a&&a.mant.length>b&&!this.allzero(a.mant,b))throw"Too many digits: "+a.toString();}};h.prototype.round=u;h.prototype.allzero=function(a,b){var c=0;0>b&&(b=0);var d=a.length-1,c=b;for(;c<=d;c++)if(0!=a[c])return!1;return!0};h.prototype.finish=function(a,b){var c=0,d=0,e=null,c=d=0;0!=a.digits&&this.mant.length>a.digits&&this.round(a);if(b&&a.form!=m.prototype.PLAIN){c=this.mant.length;d=c-1;a:for(;1<=d;d--){if(0!=this.mant[d])break a;c--;this.exp++}c<this.mant.length&&(e=Array(c),
this.arraycopy(this.mant,0,e,0,c),this.mant=e)}this.form=m.prototype.PLAIN;c=this.mant.length;d=0;for(;0<c;c--,d++)if(0!=this.mant[d]){0<d&&(e=Array(this.mant.length-d),this.arraycopy(this.mant,d,e,0,this.mant.length-d),this.mant=e);d=this.exp+this.mant.length;if(0<d){if(d>a.digits&&0!=a.digits&&(this.form=a.form),d-1<=this.MaxExp)return this}else-5>d&&(this.form=a.form);d--;if(d<this.MinExp||d>this.MaxExp){b:do{if(this.form==m.prototype.ENGINEERING&&(c=d%3,0>c&&(c=3+c),d-=c,d>=this.MinExp&&d<=this.MaxExp))break b;
throw"finish(): Exponent Overflow: "+d;}while(0)}return this}this.ind=this.iszero;if(a.form!=m.prototype.PLAIN)this.exp=0;else if(0<this.exp)this.exp=0;else if(this.exp<this.MinExp)throw"finish(): Exponent Overflow: "+this.exp;this.mant=this.ZERO.mant;return this};h.prototype.isGreaterThan=function(a){return 0<this.compareTo(a)};h.prototype.isLessThan=function(a){return 0>this.compareTo(a)};h.prototype.isGreaterThanOrEqualTo=function(a){return 0<=this.compareTo(a)};h.prototype.isLessThanOrEqualTo=
function(a){return 0>=this.compareTo(a)};h.prototype.isPositive=function(){return 0<this.compareTo(h.prototype.ZERO)};h.prototype.isNegative=function(){return 0>this.compareTo(h.prototype.ZERO)};h.prototype.isZero=function(){return this.equals(h.prototype.ZERO)};h.ROUND_CEILING=h.prototype.ROUND_CEILING=m.prototype.ROUND_CEILING;h.ROUND_DOWN=h.prototype.ROUND_DOWN=m.prototype.ROUND_DOWN;h.ROUND_FLOOR=h.prototype.ROUND_FLOOR=m.prototype.ROUND_FLOOR;h.ROUND_HALF_DOWN=h.prototype.ROUND_HALF_DOWN=m.prototype.ROUND_HALF_DOWN;
h.ROUND_HALF_EVEN=h.prototype.ROUND_HALF_EVEN=m.prototype.ROUND_HALF_EVEN;h.ROUND_HALF_UP=h.prototype.ROUND_HALF_UP=m.prototype.ROUND_HALF_UP;h.ROUND_UNNECESSARY=h.prototype.ROUND_UNNECESSARY=m.prototype.ROUND_UNNECESSARY;h.ROUND_UP=h.prototype.ROUND_UP=m.prototype.ROUND_UP;h.prototype.ispos=1;h.prototype.iszero=0;h.prototype.isneg=-1;h.prototype.MinExp=-999999999;h.prototype.MaxExp=999999999;h.prototype.MinArg=-999999999;h.prototype.MaxArg=999999999;h.prototype.plainMC=new m(0,m.prototype.PLAIN);
h.prototype.bytecar=Array(190);h.prototype.bytedig=v();h.ZERO=h.prototype.ZERO=new h("0");h.ONE=h.prototype.ONE=new h("1");h.TEN=h.prototype.TEN=new h("10");v=h;"function"===typeof define&&null!=define.amd?define({BigDecimal:v,MathContext:m}):"object"===typeof this&&(this.BigDecimal=v,this.MathContext=m)}).call(this);

View File

@ -0,0 +1,30 @@
Copyright (c) 2012 Daniel Trebbien and other contributors
Portions Copyright (c) 2003 STZ-IDA and PTV AG, Karlsruhe, Germany
Portions Copyright (c) 1995-2001 International Business Machines Corporation and others
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
ICU4J license - ICU4J 1.3.1 and later
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1995-2001 International Business Machines Corporation and others
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
--------------------------------------------------------------------------------
All trademarks and registered trademarks mentioned herein are the property of their respective owners.

1080
test/abs.js Normal file

File diff suppressed because it is too large Load Diff

456
test/base-in.js Normal file

File diff suppressed because one or more lines are too long

10818
test/base-out.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,306 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<meta name="Author" content="M Mclaughlin">
<title>Testing BigNumber against Number</title>
<style>
body, ul, form, h1, div {margin: 0; padding: 0;}
body, pre {font-family: Calibri, Arial, Sans-Serif;}
form {width: 48em; margin: 1.6em auto; border: 2px solid rgb(200, 200, 200);}
h1 {text-align: center; font-size: 1.2em; padding: 0.6em 0;
background-color: rgb(200, 200, 200)}
ul {list-style-type: none; color: rgb(85, 85, 85); padding: 1em 1em 0 2em;}
.input, ul {background-color: rgb(245, 245, 245);}
.input, .output {padding: 0 1em 1em 2em;}
.output, .methods {background-color: rgb(225, 225, 225);}
.methods {padding-bottom: 1em;}
.output {padding-bottom: 2em;}
.size {width: 80%;}
label {width: 10em; color: rgb(0, 0, 0); margin-left: 0.6em;}
label {display: inline-block;}
span, .exLabel, pre {font-size: 0.9em;}
pre {display: inline;}
.exLabel {display: inline; margin-left: 0; width: 2em;}
.arg, .result, .dp {width: 5em; margin-right: 0.8em; margin-top: 1.2em;}
.dp {width: auto;}
.exInput {margin-left: 1em;}
.code {width: 60em; margin: 0 auto; font-family: Courier New, Courier,
monospace; font-size: 0.8em;}
</style>
<script src='../../bignumber.js'></script>
</head>
<body>
<form>
<h1>Testing BigNumber against Number</h1>
<ul class='methods'>
<li>
<input type='radio' id='toExponential' name=1/>
<label for='toExponential'>toExponential</label>
<span>[ decimal places ]</span>
</li>
<li>
<input type='radio' id='toFixed' name=1/>
<label for='toFixed'>toFixed</label>
<span>[ decimal places ]</span>
</li>
<li>
<input type='radio' id='toPrecision' name=1/>
<label for='toPrecision'>toPrecision</label>
<span>[ significant digits ]</span>
</li>
<li>
<input type='radio' id='round' name=1/>
<label for='round'>round</label>
<span>[ decimal places [ , rounding mode ] ]</span>
</li>
<li>
<input type='radio' id='toFraction' name=1/>
<label for='toFraction'>toFraction</label>
<span>[ maximum denominator ]</span>
</li>
<li>
<input type='radio' id='sqrt' name=1/>
<label for='sqrt'>sqrt</label>
</li>
</ul>
<ul id='roundings'>
<li>
<input type='radio' id=0 name=2/>
<label for=0 >UP</label>
<span>Rounds away from zero</span>
</li>
<li>
<input type='radio' id=1 name=2/>
<label for=1 >DOWN</label>
<span>Rounds towards zero</span>
</li>
<li>
<input type='radio' id=2 name=2/>
<label for=2 >CEIL</label>
<span>Rounds towards +Infinity</span>
</li>
<li>
<input type='radio' id=3 name=2/>
<label for=3 >FLOOR</label>
<span>Rounds towards -Infinity</span>
</li>
<li>
<input type='radio' id=4 name=2/>
<label for=4 >HALF_UP</label>
<span>Rounds towards nearest neighbour. If equidistant, rounds up</span>
</li>
<li>
<input type='radio' id=5 name=2/>
<label for=5 >HALF_DOWN</label>
<span>Rounds towards nearest neighbour. If equidistant, rounds down</span>
</li>
<li>
<input type='radio' id=6 name=2/>
<label for=6 >HALF_EVEN</label>
<span>Rounds towards nearest neighbour. If equidistant, rounds towards even neighbour</span>
</li>
<li>
<input type='radio' id=7 name=2/>
<label for=7 >HALF_CEIL</label>
<span>Rounds towards nearest neighbour. If equidistant, rounds towards +Infinity</span>
</li>
<li>
<input type='radio' id=8 name=2/>
<label for=8 >HALF_FLOOR</label>
<span>Rounds towards nearest neighbour. If equidistant, rounds towards -Infinity</span>
</li>
</ul>
<div class='input'>
<div class='dpDiv'>
<label class='dp' id='dpLabel' for='dp'>Decimal places:</label>
<input type='text' id='dp' name='dp' size=20 />
<pre> BigNumber ERRORS:</pre>
<input class='exInput' type='radio' id='exTrue' name=3/>
<label class='exLabel' for='exTrue'>true</label>
<input class='exInput' type='radio' id='exFalse' name=3/>
<label class='exLabel' for='exFalse'>false</label>
</div>
<label class='arg' for='input'>Input:</label>
<input class='size' type='text' id='input' name='input' />
</div>
<div class='output'>
<label class='result' for='bignumber'>BigNumber:</label>
<input class='size' type='text' id='bignumber' name='bignumber' readonly />
<div id='number'>
<label class='result' for='num'>Number:</label>
<input class='size' type='text' id='num' name='num' readonly />
</div>
</div>
</form>
<div class= 'code' id='code'></div>
<script>
(function () {
var i, toFraction, lastFocus,
d = document,
$ = function (id) {return d.getElementById(id)},
$input = $('input'),
$dp = $('dp'),
$dpLabel = $('dpLabel'),
$num = $('num'),
$bignumber = $('bignumber'),
$number = $('number'),
$roundings = $('roundings'),
$exceptionsTrue = $('exTrue'),
$exceptionsFalse = $('exFalse'),
$code = $('code'),
$inputs = d.getElementsByTagName('input');
function round() {
var i, rb, method, mode, includeNumber, numVal, bignumberVal, isSqrt,
dp = ($dp.value = $dp.value.replace(/\s+/g, '')),
dpEmpty = dp === '',
input = ($input.value = $input.value.replace(/\s+/g, '')),
exceptions = $exceptionsTrue.checked,
code = 'BigNumber.config({ERRORS : ' + exceptions;
BigNumber.config({ERRORS : exceptions});
if (input) {
for (i = 0; i < 15; i++) {
rb = $inputs[i];
if (rb.checked) {
if (i < 6) method = rb.id;
else mode = rb.id;
}
}
$num.value = $bignumber.value = $code.innerHTML = '';
isSqrt = method == 'sqrt';
if (includeNumber = method != 'toFraction' && method != 'round') {
try {
numVal = isSqrt
? Math.sqrt(input)
: dpEmpty
? Number(input)[method]()
: Number(input)[method](dp);
} catch(e) {
numVal = e;
}
if (isSqrt && !dpEmpty) {
try {
BigNumber.config(dp);
} catch(e) {
$bignumber.value = e;
return;
}
code += ', DECIMAL_PLACES : ' + dp;
}
BigNumber.config({ROUNDING_MODE : mode});
code += ', ROUNDING_MODE : ' + mode;
}
code += "})<br>BigNumber('" + input + "')." + method + "(";
if (!isSqrt) {
if (method == 'round') {
if (dpEmpty) {
dp = undefined;
dpEmpty = false;
}
code += "'" + dp + "', " + mode;
} else if (!dpEmpty) code += "'" + dp + "'";
}
code += ')<br><br>';
if (includeNumber) {
if (isSqrt) {
code += "Math.sqrt('" + input + "')";
} else {
code += "Number('" + input + "')." + method + "(";
if (!dpEmpty) code += "'" + dp + "'";
code += ")";
}
}
try {
bignumberVal = dpEmpty
? new BigNumber(input)[method]()
: new BigNumber(input)[method](dp, mode);
} catch(e) {
bignumberVal = e;
}
setTimeout(function () {
$bignumber.value = bignumberVal;
if (includeNumber) $num.value = numVal;
$code.innerHTML = code;
}, 100);
if (window.console && console.log) {
input = new BigNumber(input);
console.log('\nc: ' + input.c +
'\ne: ' + input.e +
'\ns: ' + input.s);
}
}
lastFocus.focus();
}
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : false,
EXPONENTIAL_AT : 1E9,
RANGE : 1E9
});
$input.value = $dp.value = $num.value = $bignumber.value = '';
setTimeout(function () {$input.focus()}, 0);
for (i = 0; i < 15; i++) {
$inputs[i].checked = false;
$inputs[i].onclick = function () {
if (this.id >= 0) {
round();
} else {
if (this.id == 'toFraction') {
toFraction = true;
$dpLabel.innerHTML = 'Maximum denominator:';
$number.style.display = $roundings.style.display = 'none';
} else {
$dpLabel.innerHTML = this.id == 'toPrecision'
? 'Significant digits:'
: 'Decimal places:';
$number.style.display = this.id == 'round'
? 'none'
: 'block';
$roundings.style.display = 'block';
if (toFraction) toFraction = false;
}
$dp.value = $bignumber.value = $num.value = $code.innerHTML = '';
lastFocus.focus();
}
};
}
$exceptionsTrue.onclick = $exceptionsFalse.onclick = round;
$input.onfocus = $dp.onfocus = function () {
lastFocus = this;
};
$inputs[1].checked = $inputs[10].checked = $exceptionsTrue.checked = true;
document.onkeypress = function (e) {
if ((e || window.event).keyCode == 13) {
round();
return false;
} else $num.value = $bignumber.value = '';
};
})();
</script>
</body>
</html>

View File

@ -0,0 +1,477 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BigNumber Errors</title>
<script src='../../bignumber.js'></script>
</head>
<body>
<script>
var n;
document.body.innerHTML = 'BigNumber Errors written to console.';
try {
n = new BigNumber(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
BigNumber.config({ DECIMAL_PLACES : 10.3});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ DECIMAL_PLACES : -1});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ ROUNDING_MODE : 4.3});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ ROUNDING_MODE : 10});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ EXPONENTIAL_AT : 10.3});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ EXPONENTIAL_AT : 1e99});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ RANGE : 1.999});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ RANGE : 1e99});
} catch (e) {
console.error(e + '')
} try {
BigNumber.config({ ERRORS : 'ertg'});
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).pow(10.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).pow(1e99);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).round(300.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).round(1e99);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).round(null, 3.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).round(null, 9);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).toE(300.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).toE(1e99);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).toF(300.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).toF(1e99);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).toFr(300.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).toFr(-1);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).toP(300.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).toP(0);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).toS(3.3);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).toS(1);
} catch (e) {
console.error(e + '')
}
/*
* cmp, div, eq, gt, gte, lt, lte, minus, mod, plus, pow, times.
*/
try {
n = new BigNumber(2).cmp(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).cmp(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).cmp(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).cmp(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).cmp('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).cmp(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).div(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).div(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).div(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).div(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).div('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).div(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).eq(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).eq(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).eq(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).eq(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).eq('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).eq(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).gt(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gt(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gt(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gt(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gt('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gt(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).gte(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gte(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gte(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gte(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gte('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).gte(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).lt(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lt(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lt(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lt(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lt('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lt(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).lte(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lte(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lte(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lte(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lte('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).lte(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).minus(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).minus(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).minus(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).minus(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).minus('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).minus(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).mod(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).mod(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).mod(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).mod(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).mod('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).mod(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).plus(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).plus(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).plus(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).plus(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).plus('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).plus(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).pow(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).pow(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).pow(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).pow(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).pow('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).pow(8475698473265965);
} catch (e) {
console.error(e + '')
}
try {
n = new BigNumber(2).times(45324542.452466456546456);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).times(333, 2);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).times(123, 5.6);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).times(123, 37);
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).times('hello');
} catch (e) {
console.error(e + '')
} try {
n = new BigNumber(2).times(8475698473265965);
} catch (e) {
console.error(e + '')
}
</script>
</body>
</html>

View File

@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing bignumber.js</title>
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
<script src='../../bignumber.js'></script>
</head>
<body>
<script>
var arr,
passed = 0,
total = 0,
i = 0,
start = +new Date(),
methods = [
'abs',
'base-in',
'base-out',
'ceil',
'cmp',
'config',
'div',
'floor',
'minus',
'mod',
'neg',
'others',
'plus',
'pow',
'round',
'sqrt',
'times',
'toExponential',
'toFixed',
'toFraction',
'toPrecision',
'toString'
];
function load() {
var head = document.getElementsByTagName("head")[0],
script = document.createElement("script");
script.src = '../' + methods[i] + '.js';
if (!methods[i++]) {
document.body.innerHTML += '<br>IN TOTAL: ' + passed + ' of ' + total +
' tests passed in ' + ( (+new Date() - start) / 1000 ) + ' secs.<br>';
document.body.scrollIntoView(false);
return;
}
script.onload = script.onreadystatechange = function () {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
if (!count) {
document.body.innerHTML +=
'<br><span style="color: red">TEST SCRIPT FAILED - see error console.</span>';
} else {
passed += count[0];
total += count[1];
}
head.removeChild(script);
count = script = null;
document.body.innerHTML += '<br>';
document.body.scrollIntoView(false);
setTimeout(load, 0);
}
};
head.appendChild(script);
}
document.body.innerHTML += 'BIGNUMBER TESTING<br>';
load();
</script>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing bignumber.js</title>
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
<script src='../../bignumber.js'></script>
</head>
<body>
<script src='../quick-test.js'></script>
</body>
</html>

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing bignumber.js</title>
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
<script src='../../bignumber.js'></script>
</head>
<body>
<script src='../abs.js'></script>
<!-- <script src='../base-in.js'></script> -->
<!-- <script src='../base-out.js'></script> -->
<!-- <script src='../ceil.js'></script> -->
<!-- <script src='../config.js'></script> -->
<!-- <script src='../cmp.js'></script> -->
<!-- <script src='../div.js'></script> -->
<!-- <script src='../floor.js'></script> -->
<!-- <script src='../minus.js'></script> -->
<!-- <script src='../mod.js'></script> -->
<!-- <script src='../neg.js'></script> -->
<!-- <script src='../others.js'></script> -->
<!-- <script src='../plus.js'></script> -->
<!-- <script src='../pow.js'></script> -->
<!-- <script src='../round.js'></script> -->
<!-- <script src='../sqrt.js'></script> -->
<!-- <script src='../times.js'></script> -->
<!-- <script src='../toExponential.js'></script> -->
<!-- <script src='../toFixed.js'></script> -->
<!-- <script src='../toFraction.js'></script> -->
<!-- <script src='../toPrecision.js'></script> -->
<!-- <script src='../toString.js'></script> -->
</body>
</html>

208
test/ceil.js Normal file
View File

@ -0,0 +1,208 @@
var count = (function ceil(BigNumber) {
var start = +new Date(),
log,
error,
undefined,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
function T(expected, value) {
assert(String(expected), new BigNumber(String(value)).ceil().toString());
}
log('\n Testing ceil...');
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : true,
RANGE : 1E9,
EXPONENTIAL_AT : 1E9
});
T('-2075364', '-2075364.364286541923');
T('60593539780450631', '60593539780450631');
T('65937898671515', '65937898671515');
T('-39719494751819198566798', '-39719494751819198566798.578');
T('92627382695288166557', '92627382695288166556.8683774524284866028260448205069');
T('-881574', '-881574');
T('-3633239209', '-3633239209.654526163275621746013315304191073405508491056');
T('-23970335459820625362', '-23970335459820625362');
T('131869457416154038', '131869457416154038');
T('-2685', '-2685');
T('-4542227860', '-4542227860.9511298545226');
T('2416872282', '2416872281.963955669484225137349193306323379254936827');
T('-757684868752087594264588207655', '-757684868752087594264588207655.27838048392835556');
T('-438798503526', '-438798503526.2317623894721299587561697');
T('801625782231888715214665', '801625782231888715214665');
T('-91881984778675238', '-91881984778675238');
T('327765350218284325239839632047', '327765350218284325239839632046.91682741746683081459605386');
T('-7469045007691432294', '-7469045007691432294.362757245');
T('8365540212937142194319515218790', '8365540212937142194319515218789.4106658678537421977827');
T('-14108', '-14108.495051214515');
T('49104502', '49104501.10055989379655329194309526150310568683504206945625');
T('131370407', '131370406.330005158136313262837556068534122953');
T('3017', '3017');
T('-689', '-689.6944252229740521128820354989299283');
T('73441822179', '73441822178.572653');
T('-2329', '-2329.42655772223486531483602927572548264457');
T('-834103872107533086', '-834103872107533086');
T('-1501493189970435', '-1501493189970435.74866616700317');
T('70592', '70591.2244675522123484658978887');
T('4446128540401735118', '4446128540401735117.435836700611264749985822486641350492901');
T('-597273', '-597273');
T('729117', '729117');
T('504', '504');
T('4803729546823170064608098091', '4803729546823170064608098091');
T('24147026285420507467578', '24147026285420507467578');
T('-6581532150677269472829', '-6581532150677269472829.38194951340848938896000325718062365494');
T('-131279182164804751', '-131279182164804751.430589952021038264');
T('2949426983040960', '2949426983040959.8911208825380208568451907');
T('25167', '25166.125888418871654557352055849116604612621573251770362');
T('4560569286496', '4560569286495.98300685103599898554605198');
T('14', '13.763105480576616251068323541559825687');
T('176037174185746614410406167888', '176037174185746614410406167887.42317518');
T('9050999219307', '9050999219306.7846946346757664893036971777');
T('39900924', '39900924');
T('115911043168452445', '115911043168452445');
T('20962819101135667464733349384', '20962819101135667464733349383.8959025798517496777183');
T('4125789711001606948192', '4125789711001606948191.4707575965791242737346836');
T('-6935501', '-6935501.294727166142750626019282');
T('-1', '-1.518418076611593764852321765899');
T('-35416', '-35416');
T('6912783515683955988122411164549', '6912783515683955988122411164548.393');
T('658', '657.0353902852');
T('1', '0.0009');
T('1', '0.00000000000000000000000017921822306362413915');
T('1483059355427939255846407888', '1483059355427939255846407887.011361095342689876');
T('7722', '7722');
T('1', '0.00000005');
T('8551283060956479353', '8551283060956479352.5707396');
T('1', '0.000000000000000000000000019904267');
T('321978830777554620127500540', '321978830777554620127500539.339278568133088682532238002577');
T('2074', '2073.532654804291079327244387978249477171032485250998396');
T('677676305592', '677676305591.2');
T('1', '0.0000000000006');
T('39181479479778357', '39181479479778357');
T('1', '0.00000000000000000087964700066672916651');
T('896', '896');
T('115083055948552475', '115083055948552475');
T('9105942082143427451223', '9105942082143427451223');
T('1', '0.0000000000000009');
T('1', '0.00000000000000000000004');
T('1', '0.000250427721966583680168028884692015623739');
T('1', '0.000000000001585613219016120158734661293405081934');
T('1', '0.00009');
T('1', '0.000000090358252973411013592234');
T('276312604693909858428', '276312604693909858427.21965306055697011390137926559');
T('1', '0.0000252');
T(2, new BigNumber('1.000000000000000000000000000000000000001').ceil(NaN));
// ---------------------------------------------------------------- v8 start
T(0, 0);
T(0, '0.000');
T(0, -0);
T(Infinity, Infinity);
T(-Infinity, -Infinity);
T(NaN, NaN);
T(NaN, 'NaN');
T(1, 0.1);
T(1, 0.49999999999999994);
T(1, 0.5);
T(1, 0.7);
T(0, -0.1);
T(0, -0.49999999999999994);
T(0, -0.5);
T(0, -0.7);
T(1, 1);
T(2, 1.1);
T(2, 1.5);
T(2, 1.7);
T(-1, -1);
T(-1, -1.1);
T(-1, -1.5);
T(-1, -1.7);
BigNumber.config({EXPONENTIAL_AT : 100});
T(0, -1e-308);
T(-1e308, -1e308);
T('2.1e+308', '2.1e308');
T(0, '-1e-999');
T(1, '1e-999');
T(1, Number.MIN_VALUE);
T(0, -Number.MIN_VALUE);
T(Number.MAX_VALUE, Number.MAX_VALUE);
T(-Number.MAX_VALUE, -Number.MAX_VALUE);
T(Infinity, Infinity);
T(-Infinity, -Infinity);
var two_30 = 1 << 30;
T(two_30, two_30);
T(two_30 + 1, two_30 + 0.1);
T(two_30 + 1, two_30 + 0.5);
T(two_30 + 1, two_30 + 0.7);
T(two_30 - 1, two_30 - 1);
T(two_30, two_30 - 1 + 0.1);
T(two_30, two_30 - 1 + 0.5);
T(two_30, two_30 - 1 + 0.7);
T(-two_30, -two_30);
T(-two_30 + 1, -two_30 + 0.1);
T(-two_30 + 1, -two_30 + 0.5);
T(-two_30 + 1, -two_30 + 0.7);
T(-two_30 + 1, -two_30 + 1);
T(-two_30 + 2, -two_30 + 1 + 0.1);
T(-two_30 + 2, -two_30 + 1 + 0.5);
T(-two_30 + 2, -two_30 + 1 + 0.7);
var two_52 = (1 << 30) * (1 << 22);
T(two_52, two_52);
T(two_52 + 1, '4503599627370496.1');
T(two_52 + 1, '4503599627370496.5');
T(two_52 + 1, '4503599627370496.7');
T(-two_52, -two_52);
T(-two_52 + 1, '-4503599627370495.1');
T(-two_52 + 1, '-4503599627370495.5');
T(-two_52 + 1, '-4503599627370495.7');
// ------------------------------------------------------------------ v8 end
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

4127
test/cmp.js Normal file

File diff suppressed because it is too large Load Diff

557
test/config.js Normal file
View File

@ -0,0 +1,557 @@
var count = (function config(BigNumber) {
var start = +new Date(),
log,
error,
obj,
undefined,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
function assertException(func, message) {
var actual;
total++;
try {
func();
} catch (e) {
actual = e;
}
if (actual && actual.name == 'BigNumber Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a BigNumber Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
log('\n Testing config...');
obj = BigNumber.config({
DECIMAL_PLACES : 100,
ROUNDING_MODE : 0,
EXPONENTIAL_AT : 50,
RANGE : 500,
ERRORS : false
});
assert(true, obj.DECIMAL_PLACES === 100 &&
obj.ROUNDING_MODE === 0 &&
obj.EXPONENTIAL_AT[0] === -50 &&
obj.EXPONENTIAL_AT[1] === 50 &&
obj.RANGE[0] === -500 &&
obj.RANGE[1] === 500 &&
obj.ERRORS === false
);
obj = BigNumber.config( 99, 8, 32, 333, 1 );
assert(true, obj.DECIMAL_PLACES === 99 &&
obj.ROUNDING_MODE === 8 &&
obj.EXPONENTIAL_AT[0] === -32 &&
obj.EXPONENTIAL_AT[1] === 32 &&
obj.RANGE[0] === -333 &&
obj.RANGE[1] === 333 &&
obj.ERRORS === true
);
obj = BigNumber.config({
DECIMAL_PLACES : 40,
ROUNDING_MODE : 4,
EXPONENTIAL_AT : 1E9,
RANGE : 1E9,
ERRORS : true
});
obj = BigNumber.config( null, null, null, null, null );
obj = BigNumber.config( undefined, undefined, undefined, undefined, undefined );
assert(true, typeof obj === 'object');
assert(true, obj.DECIMAL_PLACES === 40);
assert(true, obj.ROUNDING_MODE === 4);
assert(true, typeof obj.EXPONENTIAL_AT === 'object');
assert(true, obj.EXPONENTIAL_AT.length === 2);
assert(true, obj.EXPONENTIAL_AT[0] === -1e9);
assert(true, obj.EXPONENTIAL_AT[1] === 1e9);
assert(true, typeof obj.RANGE === 'object');
assert(true, obj.RANGE.length === 2);
assert(true, obj.RANGE[0] === -1e9);
assert(true, obj.RANGE[1] === 1e9);
assert(true, obj.ERRORS === true);
obj = BigNumber.config({EXPONENTIAL_AT : [-7, 21], RANGE : [-324, 308]});
// DECIMAL_PLACES
assert(0, BigNumber.config(0).DECIMAL_PLACES);
assert(1, BigNumber.config(1).DECIMAL_PLACES);
assert(20, BigNumber.config(20).DECIMAL_PLACES);
assert(300000, BigNumber.config(300000).DECIMAL_PLACES);
assert(4e+8, BigNumber.config(4e8).DECIMAL_PLACES);
assert(123456789, BigNumber.config('123456789').DECIMAL_PLACES);
assert(1e9, BigNumber.config(1e9).DECIMAL_PLACES);
assert(0, BigNumber.config({DECIMAL_PLACES : 0}).DECIMAL_PLACES);
assert(1, BigNumber.config({DECIMAL_PLACES : 1}).DECIMAL_PLACES);
assert(20, BigNumber.config({DECIMAL_PLACES : 20}).DECIMAL_PLACES);
assert(300000, BigNumber.config({DECIMAL_PLACES : 300000}).DECIMAL_PLACES);
assert(4e+8, BigNumber.config({DECIMAL_PLACES : 4e8}).DECIMAL_PLACES);
assert(123456789, BigNumber.config({DECIMAL_PLACES : '123456789'}).DECIMAL_PLACES);
assert(1e9, BigNumber.config({DECIMAL_PLACES : 1e9}).DECIMAL_PLACES);
assert(1e9, BigNumber.config(null).DECIMAL_PLACES);
assert(1e9, BigNumber.config(undefined).DECIMAL_PLACES);
assert(1e9, BigNumber.config({DECIMAL_PLACES : null}).DECIMAL_PLACES);
assert(1e9, BigNumber.config({DECIMAL_PLACES : undefined}).DECIMAL_PLACES);
assertException(function () {BigNumber.config({DECIMAL_PLACES : -1})}, "DECIMAL_PLACES : -1");
assertException(function () {BigNumber.config({DECIMAL_PLACES : 0.1})}, "DECIMAL_PLACES : 0.1");
assertException(function () {BigNumber.config({DECIMAL_PLACES : 1.1})}, "DECIMAL_PLACES : 1.1");
assertException(function () {BigNumber.config({DECIMAL_PLACES : -1.1})}, "DECIMAL_PLACES : -1.1");
assertException(function () {BigNumber.config({DECIMAL_PLACES : 8.1})}, "DECIMAL_PLACES : 8.1");
assertException(function () {BigNumber.config({DECIMAL_PLACES : 1e+9 + 1})}, "DECIMAL_PLACES : 1e9 + 1");
assertException(function () {BigNumber.config({DECIMAL_PLACES : []})}, "DECIMAL_PLACES : []");
assertException(function () {BigNumber.config({DECIMAL_PLACES : {}})}, "DECIMAL_PLACES : {}");
assertException(function () {BigNumber.config({DECIMAL_PLACES : ''})}, "DECIMAL_PLACES : ''");
assertException(function () {BigNumber.config({DECIMAL_PLACES : ' '})}, "DECIMAL_PLACES : ' '");
assertException(function () {BigNumber.config({DECIMAL_PLACES : 'hi'})}, "DECIMAL_PLACES : 'hi'");
assertException(function () {BigNumber.config({DECIMAL_PLACES : '1e+9'})}, "DECIMAL_PLACES : '1e+9'");
assertException(function () {BigNumber.config({DECIMAL_PLACES : NaN})}, "DECIMAL_PLACES : NaN");
assertException(function () {BigNumber.config({DECIMAL_PLACES : Infinity})}, "DECIMAL_PLACES : Infinity");
BigNumber.config({ ERRORS : false });
assert(1e9, BigNumber.config(-1).DECIMAL_PLACES);
assert(0, BigNumber.config(0.1).DECIMAL_PLACES);
assert(1, BigNumber.config(1.99).DECIMAL_PLACES);
assert(1, BigNumber.config(-1.1).DECIMAL_PLACES);
assert(8, BigNumber.config(8.7654321).DECIMAL_PLACES);
assert(8, BigNumber.config(1e9 + 1).DECIMAL_PLACES);
assert(8, BigNumber.config([]).DECIMAL_PLACES);
assert(8, BigNumber.config({}).DECIMAL_PLACES);
assert(8, BigNumber.config('').DECIMAL_PLACES);
assert(8, BigNumber.config(' ').DECIMAL_PLACES);
assert(8, BigNumber.config('hi').DECIMAL_PLACES);
assert(1e9, BigNumber.config('1e+9').DECIMAL_PLACES);
assert(1e9, BigNumber.config(NaN).DECIMAL_PLACES);
assert(1e9, BigNumber.config(Infinity).DECIMAL_PLACES);
assert(1e9, BigNumber.config(new Date).DECIMAL_PLACES);
assert(1e9, BigNumber.config(null).DECIMAL_PLACES);
assert(1e9, BigNumber.config(undefined).DECIMAL_PLACES);
BigNumber.config({ ERRORS : 1 });
// ROUNDING_MODE
assert(0, BigNumber.config(null, 0).ROUNDING_MODE);
assert(1, BigNumber.config(null, 1).ROUNDING_MODE);
assert(2, BigNumber.config(null, 2).ROUNDING_MODE);
assert(3, BigNumber.config(null, 3).ROUNDING_MODE);
assert(4, BigNumber.config(null, 4).ROUNDING_MODE);
assert(5, BigNumber.config(null, 5).ROUNDING_MODE);
assert(6, BigNumber.config(null, 6).ROUNDING_MODE);
assert(7, BigNumber.config(null, 7).ROUNDING_MODE);
assert(8, BigNumber.config(null, 8).ROUNDING_MODE);
assert(0, BigNumber.config({ROUNDING_MODE : 0}).ROUNDING_MODE);
assert(1, BigNumber.config({ROUNDING_MODE : 1}).ROUNDING_MODE);
assert(2, BigNumber.config({ROUNDING_MODE : 2}).ROUNDING_MODE);
assert(3, BigNumber.config({ROUNDING_MODE : 3}).ROUNDING_MODE);
assert(4, BigNumber.config({ROUNDING_MODE : 4}).ROUNDING_MODE);
assert(5, BigNumber.config({ROUNDING_MODE : 5}).ROUNDING_MODE);
assert(6, BigNumber.config({ROUNDING_MODE : 6}).ROUNDING_MODE);
assert(7, BigNumber.config({ROUNDING_MODE : 7}).ROUNDING_MODE);
assert(8, BigNumber.config({ROUNDING_MODE : 8}).ROUNDING_MODE);
assert(8, BigNumber.config(null, null).ROUNDING_MODE);
assert(8, BigNumber.config(null, undefined).ROUNDING_MODE);
assert(8, BigNumber.config({ROUNDING_MODE : null}).ROUNDING_MODE);
assert(8, BigNumber.config({ROUNDING_MODE : undefined}).ROUNDING_MODE);
assertException(function () {BigNumber.config({ROUNDING_MODE : -1})}, "ROUNDING_MODE : -1");
assertException(function () {BigNumber.config({ROUNDING_MODE : 0.1})}, "ROUNDING_MODE : 0.1");
assertException(function () {BigNumber.config({ROUNDING_MODE : 1.1})}, "ROUNDING_MODE : 1.1");
assertException(function () {BigNumber.config({ROUNDING_MODE : -1.1})}, "ROUNDING_MODE : -1.1");
assertException(function () {BigNumber.config({ROUNDING_MODE : 8.1})}, "ROUNDING_MODE : 8.1");
assertException(function () {BigNumber.config({ROUNDING_MODE : 9})}, "ROUNDING_MODE : 9");
assertException(function () {BigNumber.config({ROUNDING_MODE : 11})}, "ROUNDING_MODE : 11");
assertException(function () {BigNumber.config({ROUNDING_MODE : []})}, "ROUNDING_MODE : []");
assertException(function () {BigNumber.config({ROUNDING_MODE : {}})}, "ROUNDING_MODE : {}");
assertException(function () {BigNumber.config({ROUNDING_MODE : ''})}, "ROUNDING_MODE : ''");
assertException(function () {BigNumber.config({ROUNDING_MODE : ' '})}, "ROUNDING_MODE : ' '");
assertException(function () {BigNumber.config({ROUNDING_MODE : 'hi'})}, "ROUNDING_MODE : 'hi'");
assertException(function () {BigNumber.config({ROUNDING_MODE : NaN})}, "ROUNDING_MODE : NaN");
assertException(function () {BigNumber.config({ROUNDING_MODE : Infinity})}, "ROUNDING_MODE : Infinity");
BigNumber.config({ ERRORS : 0 });
assert(8, BigNumber.config(0, -1).ROUNDING_MODE);
assert(0, BigNumber.config(0, 0.1).ROUNDING_MODE);
assert(1, BigNumber.config(0, 1.99).ROUNDING_MODE);
assert(1, BigNumber.config(0, -1.1).ROUNDING_MODE);
assert(1, BigNumber.config(0, 8.01).ROUNDING_MODE);
assert(7, BigNumber.config(0, 7.99).ROUNDING_MODE);
assert(7, BigNumber.config(0, 1e9 + 1).ROUNDING_MODE);
assert(7, BigNumber.config(0, []).ROUNDING_MODE);
assert(7, BigNumber.config(0, {}).ROUNDING_MODE);
assert(7, BigNumber.config(0, '').ROUNDING_MODE);
assert(7, BigNumber.config(0, ' ').ROUNDING_MODE);
assert(7, BigNumber.config(0, 'hi').ROUNDING_MODE);
assert(1, BigNumber.config(0, '1e+0').ROUNDING_MODE);
assert(1, BigNumber.config(0, NaN).ROUNDING_MODE);
assert(1, BigNumber.config(0, Infinity).ROUNDING_MODE);
assert(1, BigNumber.config(0, new Date).ROUNDING_MODE);
assert(1, BigNumber.config(0, null).ROUNDING_MODE);
assert(1, BigNumber.config(0, undefined).ROUNDING_MODE);
BigNumber.config({ ERRORS : true });
// EXPONENTIAL_AT
assert(true, obj.EXPONENTIAL_AT[0] === -7);
assert(true, obj.EXPONENTIAL_AT[1] === 21);
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [0.1, 1]})}, "EXPONENTIAL_AT : [0.1, 1]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [-1, -0.1]})}, "EXPONENTIAL_AT : [-1, -0.1]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [1, 1]})}, "EXPONENTIAL_AT : [1, 1]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [-1, -1]})}, "EXPONENTIAL_AT : [-1, -1]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : 1e9 + 1})}, "EXPONENTIAL_AT : 1e9 + 1");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : -1e9 - 1})}, "EXPONENTIAL_AT : -1e9 - 1");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [-1e9 - 1, 1e9]})}, "EXPONENTIAL_AT : [-1e9 - 1, 1e9]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [-1e9, 1e9 + 1]})}, "EXPONENTIAL_AT : [-1e9, 1e9 + 1]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [1e9 + 1, -1e9 - 1]})}, "EXPONENTIAL_AT : [1e9 + 1, -1e9 - 1]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [-Infinity, Infinity]})}, "EXPONENTIAL_AT : [Infinity, -Infinity]");
assertException(function () {BigNumber.config({EXPONENTIAL_AT : [Infinity, -Infinity]})}, "EXPONENTIAL_AT : [Infinity, -Infinity]");
obj = BigNumber.config();
assert(true, obj.EXPONENTIAL_AT[0] === -7);
assert(true, obj.EXPONENTIAL_AT[1] === 21);
assert(1, BigNumber.config({EXPONENTIAL_AT : 1}).EXPONENTIAL_AT[1]);
assert(-1, BigNumber.config({EXPONENTIAL_AT : 1}).EXPONENTIAL_AT[0]);
obj = BigNumber.config({EXPONENTIAL_AT : 0});
assert(true, obj.EXPONENTIAL_AT[0] === 0 && obj.EXPONENTIAL_AT[1] === 0);
obj = BigNumber.config({EXPONENTIAL_AT : -1});
assert(true, obj.EXPONENTIAL_AT[0] === -1 && obj.EXPONENTIAL_AT[1] === 1);
BigNumber.config({ ERRORS : false });
assert(1, BigNumber.config(0, 0, -1).EXPONENTIAL_AT[1]);
assert(0, BigNumber.config(0, 0, 0.1).EXPONENTIAL_AT[0]);
assert(1, BigNumber.config(0, 0, 1.99).EXPONENTIAL_AT[1]);
assert(-2, BigNumber.config(0, 0, -2.1).EXPONENTIAL_AT[0]);
assert(8, BigNumber.config(0, 0, 8.01).EXPONENTIAL_AT[1]);
assert(-7, BigNumber.config(0, 0, -7.99).EXPONENTIAL_AT[0]);
assert(7, BigNumber.config(0, 0, 1e9 + 1).EXPONENTIAL_AT[1]);
assert(7, BigNumber.config(0, 0, -1e9 - 1).EXPONENTIAL_AT[1]);
assert(-7, BigNumber.config(0, 0, []).EXPONENTIAL_AT[0]);
assert(7, BigNumber.config(0, 0, {}).EXPONENTIAL_AT[1]);
assert(-7, BigNumber.config(0, 0, '').EXPONENTIAL_AT[0]);
assert(7, BigNumber.config(0, 0, ' ').EXPONENTIAL_AT[1]);
assert(-7, BigNumber.config(0, 0, 'hi').EXPONENTIAL_AT[0]);
assert(13000, BigNumber.config(0, 0, '1.3e+4').EXPONENTIAL_AT[1]);
assert(-13000, BigNumber.config(0, 0, NaN).EXPONENTIAL_AT[0]);
assert(13000, BigNumber.config(0, 0, Infinity).EXPONENTIAL_AT[1]);
assert(-13000, BigNumber.config(0, 0, new Date).EXPONENTIAL_AT[0]);
assert(13000, BigNumber.config(0, 0, null).EXPONENTIAL_AT[1]);
assert(-13000, BigNumber.config(0, 0, undefined).EXPONENTIAL_AT[0]);
assert(-98765, BigNumber.config(0, 0, 98765.4321).EXPONENTIAL_AT[0]);
assert(98765, BigNumber.config(0, 0, -98765.4321).EXPONENTIAL_AT[1]);
assert(1, BigNumber.config(0, 0, [-98765.4321, 1]).EXPONENTIAL_AT[1]);
assert(-1, BigNumber.config(0, 0, [-1, 98765.4321]).EXPONENTIAL_AT[0]);
assert(98765, BigNumber.config(0, 0, [-1, 98765.4321]).EXPONENTIAL_AT[1]);
assert(98765, BigNumber.config(0, 0, [-1, null]).EXPONENTIAL_AT[1]);
assert(98765, BigNumber.config(0, 0, [null, 98765.4321]).EXPONENTIAL_AT[1]);
assert(-1, BigNumber.config(0, 0, [null, 98765.4321]).EXPONENTIAL_AT[0]);
BigNumber.config({ ERRORS : true });
// RANGE
assert(true, obj.RANGE[0] === -324);
assert(true, obj.RANGE[1] === 308);
assertException(function () {BigNumber.config({RANGE : [-0.9, 1]})}, "RANGE : [-0.9, 1]");
assertException(function () {BigNumber.config({RANGE : [-1, 0.9]})}, "RANGE : [-1, 0.9]");
assertException(function () {BigNumber.config({RANGE : [0, 1]})}, "RANGE : [0, 1]");
assertException(function () {BigNumber.config({RANGE : [-1, 0]})}, "RANGE : [-1, 0]");
assertException(function () {BigNumber.config({RANGE : 0})}, "RANGE : 0");
assertException(function () {BigNumber.config({RANGE : 1e9 + 1})}, "RANGE : 1e9 + 1");
assertException(function () {BigNumber.config({RANGE : -1e9 - 1})}, "RANGE : -1e9 - 1");
assertException(function () {BigNumber.config({RANGE : [-1e9 - 1, 1e9 + 1]})}, "RANGE : [-1e9 - 1, 1e9 + 1]");
assertException(function () {BigNumber.config({RANGE : [1e9 + 1, -1e9 - 1]})}, "RANGE : [1e9 + 1, -1e9 - 1]");
assertException(function () {BigNumber.config({RANGE : Infinity})}, "RANGE : Infinity");
assertException(function () {BigNumber.config({RANGE : "-Infinity"})}, "RANGE : '-Infinity'");
assertException(function () {BigNumber.config({RANGE : [-Infinity, Infinity]})}, "RANGE : [-Infinity, Infinity]");
assertException(function () {BigNumber.config({RANGE : [Infinity, -Infinity]})}, "RANGE : [Infinity, -Infinity]");
obj = BigNumber.config();
assert(true, obj.RANGE[0] === -324);
assert(true, obj.RANGE[1] === 308);
assert(1, BigNumber.config({RANGE : 1}).RANGE[1]);
assert(-1, BigNumber.config({RANGE : 1}).RANGE[0]);
obj = BigNumber.config({RANGE : 1});
assert(true, obj.RANGE[0] === -1 && obj.RANGE[1] === 1);
obj = BigNumber.config({RANGE : -1});
assert(true, obj.RANGE[0] === -1 && obj.RANGE[1] === 1);
BigNumber.config({ ERRORS : 0 });
assert(1, BigNumber.config(0, 0, 0, -1).RANGE[1]);
assert(-1, BigNumber.config(0, 0, 0, 0.1).RANGE[0]);
assert(1, BigNumber.config(0, 0, 0, 1.99).RANGE[1]);
assert(-2, BigNumber.config(0, 0, 0, -2.1).RANGE[0]);
assert(8, BigNumber.config(0, 0, 0, 8.01).RANGE[1]);
assert(-7, BigNumber.config(0, 0, 0, -7.99).RANGE[0]);
assert(7, BigNumber.config(0, 0, 0, 1e9 + 1).RANGE[1]);
assert(7, BigNumber.config(0, 0, 0, -1e9 - 1).RANGE[1]);
assert(-7, BigNumber.config(0, 0, 0, []).RANGE[0]);
assert(7, BigNumber.config(0, 0, 0, {}).RANGE[1]);
assert(-7, BigNumber.config(0, 0, 0, '').RANGE[0]);
assert(7, BigNumber.config(0, 0, 0, ' ').RANGE[1]);
assert(-7, BigNumber.config(0, 0, 0, 'hi').RANGE[0]);
assert(13000, BigNumber.config(0, 0, 0, '1.3e+4').RANGE[1]);
assert(-13000, BigNumber.config(0, 0, 0, NaN).RANGE[0]);
assert(13000, BigNumber.config(0, 0, 0, Infinity).RANGE[1]);
assert(-13000, BigNumber.config(0, 0, 0, new Date).RANGE[0]);
assert(13000, BigNumber.config(0, 0, 0, null).RANGE[1]);
assert(-13000, BigNumber.config(0, 0, 0, undefined).RANGE[0]);
assert(-98765, BigNumber.config(0, 0, 0, 98765.4321).RANGE[0]);
assert(98765, BigNumber.config(0, 0, 0, -98765.4321).RANGE[1]);
assert(1, BigNumber.config(0, 0, 0, [-98765.4321, 1]).RANGE[1]);
assert(-1, BigNumber.config(0, 0, 0, [-1, 98765.4321]).RANGE[0]);
assert(98765, BigNumber.config(0, 0, 0, [-1, 98765.4321]).RANGE[1]);
assert(98765, BigNumber.config(0, 0, 0, [-1, null]).RANGE[1]);
assert(98765, BigNumber.config(0, 0, 0, [null, 98765.4321]).RANGE[1]);
assert(-1, BigNumber.config(0, 0, 0, [null, 98765.4321]).RANGE[0]);
BigNumber.config({ ERRORS : true });
// ERRORS
assert(false, BigNumber.config(null, null, null, null, 0).ERRORS);
assert(true, BigNumber.config(null, null, null, null, 1).ERRORS);
assert(false, BigNumber.config(null, null, null, null, false).ERRORS);
assert(true, BigNumber.config(null, null, null, null, true).ERRORS);
assert(false, BigNumber.config({ERRORS : 0}).ERRORS);
assert(true, BigNumber.config({ERRORS : 1}).ERRORS);
assert(false, BigNumber.config({ERRORS : false}).ERRORS);
assert(true, BigNumber.config({ERRORS : true}).ERRORS);
assert(true, BigNumber.config(null, null, null, null, null).ERRORS);
assert(true, BigNumber.config(null, null, null, null, undefined).ERRORS);
assert(true, BigNumber.config({ERRORS : null}).ERRORS);
assert(true, BigNumber.config({ERRORS : undefined}).ERRORS);
assertException(function () {BigNumber.config({ERRORS : 'hiya'})}, "ERRORS : 'hiya'");
assertException(function () {BigNumber.config({ERRORS : 'true'})}, "ERRORS : 'true'");
assertException(function () {BigNumber.config({ERRORS : 'false'})}, "ERRORS : 'false'");
assertException(function () {BigNumber.config({ERRORS : '0'})}, "ERRORS : '0'");
assertException(function () {BigNumber.config({ERRORS : '1'})}, "ERRORS : '1'");
assertException(function () {BigNumber.config({ERRORS : -1})}, "ERRORS : -1");
assertException(function () {BigNumber.config({ERRORS : 0.1})}, "ERRORS : 0.1");
assertException(function () {BigNumber.config({ERRORS : 1.1})}, "ERRORS : 1.1");
assertException(function () {BigNumber.config({ERRORS : []})}, "ERRORS : []");
assertException(function () {BigNumber.config({ERRORS : {}})}, "ERRORS : {}");
assertException(function () {BigNumber.config({ERRORS : ''})}, "ERRORS : ''");
assertException(function () {BigNumber.config({ERRORS : ' '})}, "ERRORS : ' '");
assertException(function () {BigNumber.config({ERRORS : NaN})}, "ERRORS : NaN");
assertException(function () {BigNumber.config({ERRORS : Infinity})}, "ERRORS : Infinity");
assert(true, BigNumber.config().ERRORS);
BigNumber.config({ ERRORS : false });
assert(false, BigNumber.config(null, null, null, null, 0).ERRORS);
assert(false, BigNumber.config(null, null, null, null, 1.1).ERRORS);
assert(false, BigNumber.config(null, null, null, null, false).ERRORS);
assert(true, BigNumber.config(null, null, null, null, 1).ERRORS);
assert(false, BigNumber.config(null, null, null, null, 0).ERRORS);
assert(false, BigNumber.config(null, null, null, null, '1').ERRORS);
assert(false, BigNumber.config(null, null, null, null, 'true').ERRORS);
assert(false, BigNumber.config(null, null, null, null, false).ERRORS);
assert(false, BigNumber.config({ERRORS : null}).ERRORS);
assert(false, BigNumber.config({ERRORS : undefined}).ERRORS);
assert(false, BigNumber.config({ERRORS : NaN}).ERRORS);
assert(false, BigNumber.config({ERRORS : 'd'}).ERRORS);
assert(false, BigNumber.config({ERRORS : []}).ERRORS);
assert(false, BigNumber.config({ERRORS : {}}).ERRORS);
assert(false, BigNumber.config({ERRORS : new Date}).ERRORS);
assert(true, BigNumber.config({ERRORS : Boolean(1)}).ERRORS);
assert(true, BigNumber.config({ERRORS : Boolean(true)}).ERRORS);
assert(false, BigNumber.config({ERRORS : Boolean(0)}).ERRORS);
assert(false, BigNumber.config({ERRORS : Boolean(false)}).ERRORS);
assert(true, BigNumber.config({ERRORS : Boolean('false')}).ERRORS);
// Test constructor parsing.
BigNumber.config({
DECIMAL_PLACES : 40,
ROUNDING_MODE : 4,
EXPONENTIAL_AT : 1E9,
RANGE : 1E9,
ERRORS : true
});
assert('NaN', new BigNumber(NaN).toS());
assert('NaN', new BigNumber('NaN').toS());
assert('NaN', new BigNumber(' NaN').toS());
assert('NaN', new BigNumber('NaN ').toS());
assert('NaN', new BigNumber(' NaN ').toS());
assert('NaN', new BigNumber('+NaN').toS());
assert('NaN', new BigNumber(' +NaN').toS());
assert('NaN', new BigNumber('+NaN ').toS());
assert('NaN', new BigNumber(' +NaN ').toS());
assert('NaN', new BigNumber('-NaN').toS());
assert('NaN', new BigNumber(' -NaN').toS());
assert('NaN', new BigNumber('-NaN ').toS());
assert('NaN', new BigNumber(' -NaN ').toS());
assertException(function () {new BigNumber('+ NaN')}, "+ NaN");
assertException(function () {new BigNumber('- NaN')}, "- NaN");
assertException(function () {new BigNumber(' + NaN')}, " + NaN");
assertException(function () {new BigNumber(' - NaN')}, " - NaN");
assertException(function () {new BigNumber('. NaN')}, ". NaN");
assertException(function () {new BigNumber('.-NaN')}, ".-NaN");
assertException(function () {new BigNumber('.+NaN')}, ".+NaN");
assertException(function () {new BigNumber('-.NaN')}, "-.NaN");
assertException(function () {new BigNumber('+.NaN')}, "+.NaN");
assert('Infinity', new BigNumber(Infinity).toS());
assert('Infinity', new BigNumber('Infinity').toS());
assert('Infinity', new BigNumber(' Infinity').toS());
assert('Infinity', new BigNumber('Infinity ').toS());
assert('Infinity', new BigNumber(' Infinity ').toS());
assert('Infinity', new BigNumber('+Infinity').toS());
assert('Infinity', new BigNumber(' +Infinity').toS());
assert('Infinity', new BigNumber('+Infinity ').toS());
assert('Infinity', new BigNumber(' +Infinity ').toS());
assert('-Infinity', new BigNumber('-Infinity').toS());
assert('-Infinity', new BigNumber(' -Infinity').toS());
assert('-Infinity', new BigNumber('-Infinity ').toS());
assert('-Infinity', new BigNumber(' -Infinity ').toS());
assertException(function () {new BigNumber('+ Infinity')}, "+ Infinity");
assertException(function () {new BigNumber(' + Infinity')}, " + Infinity");
assertException(function () {new BigNumber('- Infinity')}, "- Infinity");
assertException(function () {new BigNumber(' - Infinity')}, " - Infinity");
assertException(function () {new BigNumber('.Infinity')}, ".Infinity");
assertException(function () {new BigNumber('. Infinity')}, ". Infinity");
assertException(function () {new BigNumber('.-Infinity')}, ".-Infinity");
assertException(function () {new BigNumber('.+Infinity')}, ".+Infinity");
assertException(function () {new BigNumber('-.Infinity')}, "-.Infinity");
assertException(function () {new BigNumber('+.Infinity')}, "+.Infinity");
assert('0', new BigNumber(0).toS());
assert('0', new BigNumber(-0).toS());
assert('0', new BigNumber('+0').toS());
assert('0', new BigNumber('-0').toS());
assert('0', new BigNumber(' +0').toS());
assert('0', new BigNumber(' -0').toS());
assert('0', new BigNumber(' +0 ').toS());
assert('0', new BigNumber(' -0 ').toS());
assert('0', new BigNumber('+.0').toS());
assert('0', new BigNumber('-.0').toS());
assert('0', new BigNumber(' +.0').toS());
assert('0', new BigNumber(' -.0').toS());
assert('0', new BigNumber(' +.0 ').toS());
assert('0', new BigNumber(' -.0 ').toS());
assertException(function () {new BigNumber('+-0')}, "+-0");
assertException(function () {new BigNumber('-+0')}, "-+0");
assertException(function () {new BigNumber('--0')}, "--0");
assertException(function () {new BigNumber('++0')}, "++0");
assertException(function () {new BigNumber('.-0')}, ".-0");
assertException(function () {new BigNumber('.+0')}, ".+0");
assertException(function () {new BigNumber('. 0')}, ". 0");
assertException(function () {new BigNumber('..0')}, "..0");
assertException(function () {new BigNumber('+.-0')}, "+.-0");
assertException(function () {new BigNumber('-.+0')}, "-.+0");
assertException(function () {new BigNumber('+. 0')}, "+. 0");
assertException(function () {new BigNumber('-. 0')}, "-. 0");
assert('2', new BigNumber('+2').toS());
assert('-2', new BigNumber('-2').toS());
assert('2', new BigNumber(' +2').toS());
assert('-2', new BigNumber(' -2').toS());
assert('2', new BigNumber(' +2 ').toS());
assert('-2', new BigNumber(' -2 ').toS());
assert('0.2', new BigNumber('+.2').toS());
assert('-0.2', new BigNumber('-.2').toS());
assert('0.2', new BigNumber(' +.2').toS());
assert('-0.2', new BigNumber(' -.2').toS());
assert('0.2', new BigNumber(' +.2 ').toS());
assert('-0.2', new BigNumber(' -.2 ').toS());
assertException(function () {new BigNumber('+-2')}, "+-2");
assertException(function () {new BigNumber('-+2')}, "-+2");
assertException(function () {new BigNumber('--2')}, "--2");
assertException(function () {new BigNumber('++2')}, "++2");
assertException(function () {new BigNumber('.-2')}, ".-2");
assertException(function () {new BigNumber('.+2')}, ".+2");
assertException(function () {new BigNumber('. 2')}, ". 2");
assertException(function () {new BigNumber('..2')}, "..2");
assertException(function () {new BigNumber('+.-2')}, "+.-2");
assertException(function () {new BigNumber('-.+2')}, "-.+2");
assertException(function () {new BigNumber('+. 2')}, "+. 2");
assertException(function () {new BigNumber('-. 2')}, "-. 2");
assertException(function () {new BigNumber('+2..')}, "+2..");
assertException(function () {new BigNumber('-2..')}, "-2..");
assertException(function () {new BigNumber('-.2.')}, "-.2.");
assertException(function () {new BigNumber('+.2.')}, "+.2.");
assertException(function () {new BigNumber('.-20.')}, ".-20.");
assertException(function () {new BigNumber('.+20.')}, ".+20.");
assertException(function () {new BigNumber('. 20.')}, ". 20.");
assertException(function () {new BigNumber(undefined)}, "undefined");
assertException(function () {new BigNumber([])}, "[]");
assertException(function () {new BigNumber('')}, "''");
assertException(function () {new BigNumber(null)}, "null");
assertException(function () {new BigNumber(' ')}, "' '");
assertException(function () {new BigNumber('nan')}, "nan");
assertException(function () {new BigNumber('23er')}, "23er");
assertException(function () {new BigNumber('e4')}, "e4");
assertException(function () {new BigNumber('0x434')}, "0x434");
assertException(function () {new BigNumber('--45')}, "--45");
assertException(function () {new BigNumber('+-2')}, "+-2");
assertException(function () {new BigNumber('0 0')}, "0 0");
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

19930
test/div.js Normal file

File diff suppressed because it is too large Load Diff

39
test/every-test.js Normal file
View File

@ -0,0 +1,39 @@
var arr,
passed = 0,
total = 0,
start = +new Date();
console.log( '\n STARTING TESTS...\n' );
[
'abs',
'base-in',
'base-out',
'ceil',
'cmp',
'config',
'div',
'floor',
'minus',
'mod',
'neg',
'others',
'plus',
'pow',
'round',
'sqrt',
'times',
'toExponential',
'toFixed',
'toFraction',
'toPrecision',
'toString'
]
.forEach( function (method) {
arr = require('./' + method);
passed += arr[0];
total += arr[1];
});
console.log( '\n IN TOTAL: ' + passed + ' of ' + total + ' tests passed in ' +
( (+new Date() - start) / 1000 ) + ' secs.\n' );

216
test/floor.js Normal file
View File

@ -0,0 +1,216 @@
var count = (function floor(BigNumber) {
var start = +new Date(),
log,
error,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
function T(expected, value) {
assert(String(expected), new BigNumber(String(value)).floor().toString());
}
log('\n Testing floor...');
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : true,
RANGE : 1E9,
EXPONENTIAL_AT : 1E9
});
T('-2075365', '-2075364.364286541923');
T('60593539780450631', '60593539780450631');
T('65937898671515', '65937898671515');
T('-39719494751819198566799', '-39719494751819198566798.578');
T('92627382695288166556', '92627382695288166556.8683774524284866028260448205069');
T('-881574', '-881574');
T('-3633239210', '-3633239209.654526163275621746013315304191073405508491056');
T('-23970335459820625362', '-23970335459820625362');
T('131869457416154038', '131869457416154038');
T('-2685', '-2685');
T('-4542227861', '-4542227860.9511298545226');
T('2416872281', '2416872281.963955669484225137349193306323379254936827');
T('-757684868752087594264588207656', '-757684868752087594264588207655.27838048392835556');
T('-438798503527', '-438798503526.2317623894721299587561697');
T('801625782231888715214665', '801625782231888715214665');
T('-91881984778675238', '-91881984778675238');
T('327765350218284325239839632046', '327765350218284325239839632046.91682741746683081459605386');
T('-7469045007691432295', '-7469045007691432294.362757245');
T('8365540212937142194319515218789', '8365540212937142194319515218789.4106658678537421977827');
T('-14109', '-14108.495051214515');
T('49104501', '49104501.10055989379655329194309526150310568683504206945625');
T('131370406', '131370406.330005158136313262837556068534122953');
T('3017', '3017');
T('-690', '-689.6944252229740521128820354989299283');
T('73441822178', '73441822178.572653');
T('-2330', '-2329.42655772223486531483602927572548264457');
T('-834103872107533086', '-834103872107533086');
T('-1501493189970436', '-1501493189970435.74866616700317');
T('70591', '70591.2244675522123484658978887');
T('4446128540401735117', '4446128540401735117.435836700611264749985822486641350492901');
T('-597273', '-597273');
T('729117', '729117');
T('504', '504');
T('4803729546823170064608098091', '4803729546823170064608098091');
T('24147026285420507467578', '24147026285420507467578');
T('-6581532150677269472830', '-6581532150677269472829.38194951340848938896000325718062365494');
T('-131279182164804752', '-131279182164804751.430589952021038264');
T('2949426983040959', '2949426983040959.8911208825380208568451907');
T('25166', '25166.125888418871654557352055849116604612621573251770362');
T('4560569286495', '4560569286495.98300685103599898554605198');
T('13', '13.763105480576616251068323541559825687');
T('176037174185746614410406167887', '176037174185746614410406167887.42317518');
T('9050999219306', '9050999219306.7846946346757664893036971777');
T('39900924', '39900924');
T('115911043168452445', '115911043168452445');
T('20962819101135667464733349383', '20962819101135667464733349383.8959025798517496777183');
T('4125789711001606948191', '4125789711001606948191.4707575965791242737346836');
T('-6935502', '-6935501.294727166142750626019282');
T('-2', '-1.518418076611593764852321765899');
T('-35416', '-35416');
T('6912783515683955988122411164548', '6912783515683955988122411164548.393');
T('657', '657.0353902852');
T('0', '0.0009');
T('0', '0.00000000000000000000000017921822306362413915');
T('1483059355427939255846407887', '1483059355427939255846407887.011361095342689876');
T('7722', '7722');
T('0', '0.00000005');
T('8551283060956479352', '8551283060956479352.5707396');
T('0', '0.000000000000000000000000019904267');
T('321978830777554620127500539', '321978830777554620127500539.339278568133088682532238002577');
T('2073', '2073.532654804291079327244387978249477171032485250998396');
T('677676305591', '677676305591.2');
T('0', '0.0000000000006');
T('39181479479778357', '39181479479778357');
T('0', '0.00000000000000000087964700066672916651');
T('896', '896');
T('115083055948552475', '115083055948552475');
T('9105942082143427451223', '9105942082143427451223');
T('0', '0.0000000000000009');
T('0', '0.00000000000000000000004');
T('0', '0.000250427721966583680168028884692015623739');
T('0', '0.000000000001585613219016120158734661293405081934');
T('0', '0.00009');
T('0', '0.000000090358252973411013592234');
T('276312604693909858427', '276312604693909858427.21965306055697011390137926559');
T('0', '0.0000252');
// ---------------------------------------------------------------- v8 start
T(0, 0);
T(0, '0.000');
T(-0, -0);
T(Infinity, Infinity);
T(-Infinity, -Infinity);
T(NaN, NaN);
T(0, 0.1);
T(0, 0.49999999999999994);
T(0, 0.5);
T(0, 0.7);
T(-1, -0.1);
T(-1, -0.49999999999999994);
T(-1, -0.5);
T(-1, -0.7);
T(1, 1);
T(1, 1.1);
T(1, 1.5);
T(1, 1.7);
T(-1, -1);
T(-2, -1.1);
T(-2, -1.5);
T(-2, -1.7);
BigNumber.config({EXPONENTIAL_AT : 100});
T(-1, -1e-308);
T(-1e308, -1e308);
T('2.1e+308', '2.1e308');
T(-1, '-1e-999');
T(0, '1e-999');
T(0, Number.MIN_VALUE);
T(-1, -Number.MIN_VALUE);
T(Number.MAX_VALUE, Number.MAX_VALUE);
T(-Number.MAX_VALUE, -Number.MAX_VALUE);
T(Infinity, Infinity);
T(-Infinity, -Infinity);
var two_30 = 1 << 30;
T(two_30, two_30);
T(two_30, two_30 + 0.1);
T(two_30, two_30 + 0.5);
T(two_30, two_30 + 0.7);
T(two_30 - 1, two_30 - 1);
T(two_30 - 1, two_30 - 1 + 0.1);
T(two_30 - 1, two_30 - 1 + 0.5);
T(two_30 - 1, two_30 - 1 + 0.7);
T(-two_30, -two_30);
T(-two_30, -two_30 + 0.1);
T(-two_30, -two_30 + 0.5);
T(-two_30, -two_30 + 0.7);
T(-two_30 + 1, -two_30 + 1);
T(-two_30 + 1, -two_30 + 1 + 0.1);
T(-two_30 + 1, -two_30 + 1 + 0.5);
T(-two_30 + 1, -two_30 + 1 + 0.7);
var two_52 = (1 << 30) * (1 << 22);
T(two_52, two_52);
T(two_52, two_52 + 0.1);
T(two_52, two_52 + 0.5);
T(two_52 + 1, two_52 + 0.7);
T(two_52 - 1, two_52 - 1);
T(two_52 - 1, two_52 - 1 + 0.1);
T(two_52 - 1, two_52 - 1 + 0.5);
T(two_52 - 1, two_52 - 1 + 0.7);
T(-two_52, -two_52);
T(-two_52, -two_52 + 0.1);
T(-two_52, -two_52 + 0.5);
T(-two_52, -two_52 + 0.7);
T(-two_52 + 1, -two_52 + 1);
T(-two_52 + 1, -two_52 + 1 + 0.1);
T(-two_52 + 1, -two_52 + 1 + 0.5);
T(-two_52 + 1, -two_52 + 1 + 0.7);
// ------------------------------------------------------------------ v8 end
assert('1', new BigNumber('1.9999999999').floor(NaN).toString());
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

1846
test/minus.js Normal file

File diff suppressed because it is too large Load Diff

1905
test/mod.js Normal file

File diff suppressed because it is too large Load Diff

544
test/neg.js Normal file
View File

@ -0,0 +1,544 @@
var count = (function neg(BigNumber) {
var start = +new Date(),
log,
error,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
function T(expected, value){
assert(String(expected), new BigNumber(value).neg().toString());
}
function isMinusZero(n) {
return n.toString() === '0' && n.s == -1;
}
log('\n Testing neg...');
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : true,
RANGE : 1E9,
EXPONENTIAL_AT : [-7, 21]
});
T(-4, 4);
T(-2147483648, 2147483648);
T(-0.25, 0.25);
T(-0.0625, 0.0625);
T(-1, 1);
T(1, -1);
T(0, 0);
T(NaN, NaN);
T(-Infinity, Infinity);
T(-Infinity, +Infinity);
T(Infinity, -Infinity);
T(+Infinity, -Infinity);
T('0', '0');
T('-238', '238');
T('1.3e-11', '-0.000000000013');
T('-33.1', '33.1');
T('2.61', '-2.61');
T('-4', '4.0');
T('-5.8', '5.8');
T('-3.52e-7', '0.000000352');
T('190', '-190');
T('4.47', '-4.47');
T('6.9525e-12', '-0.0000000000069525');
T('1.3', '-1.3');
T('-6.21', '6.21');
T('2', '-2');
T('-1', '1');
T('147.857', '-147.857');
T('-26.517', '26.517');
T('-3', '3');
T('5', '-5');
T('204', '-204');
T('2.1e-8', '-0.000000021');
T('3.7015e-7', '-0.00000037015');
T('-50.1839', '50.1839');
T('44768.1', '-44768.1');
T('3.8e-15', '-0.0000000000000038');
T('-7.4379', '7.4379');
T('1.5', '-1.5');
T('6.0399', '-6.0399');
T('109.07', '-109.070');
T('1582', '-1582');
T('-772', '772');
T('-6.7824e-14', '0.000000000000067824');
T('-1.819e-8', '0.00000001819');
T('-3e-15', '0.0000000000000030');
T('-424120', '424120');
T('-1814.54', '1814.54');
T('-4.295e-17', '0.00000000000000004295');
T('-5', '5');
T('2152', '-2152');
T('4.6', '-4.6');
T('1.9', '-1.9');
T('-2', '2.0');
T('-0.00036', '0.00036');
T('-0.000006962', '0.000006962');
T('3.6', '-3.6');
T('-1.1495e-14', '0.000000000000011495');
T('-312.4', '312.4');
T('4.3e-10', '-0.00000000043');
T('5', '-5');
T('-1.8911e-8', '0.000000018911');
T('4963.53', '-4963.53');
T('-4.3934e-10', '0.00000000043934');
T('-1.3', '1.30');
T('-1', '1.0');
T('-68.32', '68.32');
T('0.014836', '-0.014836');
T('8', '-8');
T('2.1351', '-2.13510');
T('162224', '-162224');
T('3e-19', '-0.00000000000000000030');
T('0.00004985', '-0.00004985');
T('28.9321', '-28.9321');
T('-2', '2');
T('-16688', '16688');
T('-1', '1');
T('5', '-5');
T('-20', '20.0');
T('-1.9', '1.9');
T('3', '-3');
T('185640', '-185640');
T('-0.0000058', '0.0000058');
T('9.67e-13', '-0.000000000000967');
T('-707.98', '707.98');
T('2.57917', '-2.57917');
T('-1.3', '1.3');
T('-4.2655', '4.2655');
T('-149.6', '149.6');
T('-1.32383', '1.32383');
T('-26.925', '26.925');
T('-0.00013', '0.00013');
T('-6868', '6868');
T('7', '-7');
T('-5e-9', '0.0000000050');
T('3.2555e-16', '-0.00000000000000032555');
T('1.42768e-13', '-0.000000000000142768');
T('11.2962', '-11.2962');
T('3186.7', '-3186.7');
T('-6.9', '6.9');
T('-6.2618e-7', '0.00000062618');
T('8', '-8');
T('-8.04', '8.04');
T('-22', '22');
T('-750.6', '750.6');
T('12.803', '-12.803');
T('-20513.4', '20513.4');
T('114781', '-114781');
T('-16.9046', '16.9046');
T('4.6e-7', '-0.00000046');
T('-31399', '31399');
T('1.04', '-1.04');
T('-51.2544', '51.2544');
T('1.023e-15', '-0.000000000000001023');
T('281', '-281');
T('-128315', '128315');
T('20.2', '-20.2');
T('9', '-9');
T('-10', '10');
T('-1.92262e-17', '0.0000000000000000192262');
T('-0.0023', '0.0023');
T('5', '-5');
T('7', '-7');
T('13.72', '-13.72');
T('98068', '-98068');
T('3.2', '-3.2');
T('1.1', '-1.1');
T('-3.97e-18', '0.000000000000000003970');
T('0.00334824', '-0.00334824');
T('-5.4892e-8', '0.000000054892');
T('-1', '1.0');
T('-2.8135e-8', '0.000000028135');
T('-1.816e-13', '0.0000000000001816');
T('199724', '-199724');
T('-19.4', '19.40');
T('-12.74', '12.74');
T('-2171.8', '2171.8');
T('-2.7', '2.7');
T('1', '-1.0');
T('21779', '-21779');
T('8.9e-12', '-0.0000000000089');
T('-4.51', '4.51');
T('2.6', '-2.6');
T('-0.00016', '0.000160');
T('6', '-6');
T('50.566', '-50.566');
T('-16.2', '16.2');
T('-7.9156e-20', '0.000000000000000000079156');
T('-2262.4', '2262.4');
T('6468.59', '-6468.59');
T('0.077', '-0.077');
T('-465.83', '465.83');
T('-604.59', '604.59');
T('-0.0014917', '0.0014917');
T('-2.8954', '2.8954');
T('1', '-1');
T('1942', '-1942');
T('-182.308', '182.308');
T('-17.8', '17.8');
T('39472.5', '-39472.5');
T('214.21', '-214.21');
T('-40.11', '40.11');
T('-3', '3');
T('141149', '-141149');
T('-8', '8.0');
T('-2.9', '2.9');
T('44.51', '-44.51');
T('-5.3', '5.3');
T('0.05498', '-0.054980');
T('7', '-7');
T('-922', '922.0');
T('-1.5146e-14', '0.000000000000015146');
T('-0.000008117', '0.000008117');
T('1', '-1');
T('5452.81', '-5452.81');
T('751745', '-751745');
T('-2.7', '2.7');
T('5.1', '-5.1');
T('-1', '1');
T('-524124', '524124');
T('-183.5', '183.50');
T('44856.8', '-44856.8');
T('0.00000387', '-0.00000387');
T('-3.0544e-14', '0.000000000000030544');
T('1.3', '-1.3');
T('-0.0019273', '0.0019273');
T('75428', '-75428');
T('-91.7925', '91.7925');
T('44.5', '-44.5');
T('-2', '2');
T('5.3', '-5.3');
T('-57', '57');
T('-2.53e-9', '0.00000000253');
T('18258', '-18258');
T('0.829', '-0.829');
T('-4', '4');
T('-1', '1');
T('10.289', '-10.289');
T('319', '-319');
T('2.4', '-2.4');
T('89.9207', '-89.9207');
T('-9.06122e-17', '0.0000000000000000906122');
T('-102.639', '102.639');
T('948.5', '-948.50');
T('-610.7', '610.7');
T('-1.61', '1.61');
T('-99.042', '99.042');
T('3.0232', '-3.0232');
T('-15', '15');
T('-3.835', '3.835');
T('-7', '7');
T('1', '-1');
T('21.46', '-21.46');
T('2', '-2');
T('-2077.79', '2077.79');
T('-14.7446', '14.7446');
T('-9.11e-12', '0.00000000000911');
T('1.2', '-1.2');
T('-105851', '105851');
T('24.561', '-24.561');
T('780', '-780');
T('3.82122', '-3.82122');
T('9564', '-9564');
T('-13.21', '13.21');
T('25020.5', '-25020.5');
T('-5678.6', '5678.6');
T('1', '-1.0');
T('2.6', '-2.6');
T('9.6e-16', '-0.000000000000000960');
T('12.6', '-12.6');
T('-5', '5');
T('-537', '537');
T('-85', '85');
T('758.15', '-758.15');
T('-67.55', '67.55');
T('-9444', '9444');
T('21.4', '-21.4');
T('2.5', '-2.5');
T('489311', '-489311');
T('6.8', '-6.8');
T('4.29', '-4.29');
T('23982', '-23982.0');
T('-0.0111781', '0.0111781');
T('4.96e-20', '-0.0000000000000000000496');
T('-40.5481', '40.5481');
T('-32.52', '32.52');
T('-7.4', '7.4');
T('1008', '-1008');
T('1.2', '-1.2');
T('-5', '5.0');
T('-2463.4', '2463.4');
T('7.363', '-7.363');
T('2.8', '-2.8');
T('-14498', '14498');
T('201', '-201');
T('3.2', '-3.2');
T('-3.05', '3.05');
T('1.1', '-1.1');
T('-380.4', '380.4');
T('13399', '-13399');
T('-20.44', '20.44');
T('1.6', '-1.6');
T('2.1234e-10', '-0.00000000021234');
T('4404.1', '-4404.1');
T('2.4345', '-2.4345');
T('-117.256', '117.256');
T('-6.025', '6.025');
T('18.43', '-18.43');
T('-47.5', '47.5');
T('45.1', '-45.1');
T('-3806.5', '3806.5');
T('-4.6', '4.6');
T('-1.3', '1.3');
T('-74.6', '74.60');
T('-16.2088', '16.2088');
T('788.6', '-788.6');
T('-0.29', '0.29');
T('1', '-1');
T('-4.058', '4.058');
T('5', '-5.0');
T('0.00612', '-0.00612');
T('-14317', '14317');
T('-1.1801', '1.1801');
T('-32.6', '32.6');
T('57248', '-57248');
T('-103', '103');
T('-1.4', '1.4');
T('228', '-228');
T('92.8', '-92.8');
T('3.46e-17', '-0.0000000000000000346');
T('-15747', '15747');
T('16.36', '-16.360');
T('0.00223', '-0.00223');
T('244', '-244');
T('3.8', '-3.8');
T('-604.2', '604.2');
T('1.03', '-1.03');
T('1487', '-1487');
T('7', '-7');
T('45', '-45.00');
T('2.55374e-10', '-0.000000000255374');
T('3', '-3');
T('-5.5', '5.5');
T('-5.4', '5.4');
T('-9', '9');
T('-1627.2', '1627.2');
T('1.0805e-16', '-0.00000000000000010805');
T('-14.0548', '14.0548');
T('-207137', '207137');
T('3.8', '-3.8');
T('-33.4785', '33.4785');
T('4.28626', '-4.28626');
T('-4', '4');
T('-6', '6');
T('-1', '1');
T('-44.951', '44.951');
T('29.7', '-29.7');
T('-121.17', '121.17');
T('480', '-480');
T('-2.696', '2.696');
T('-3708.62', '3708.62');
T('2.8', '-2.8');
T('17842', '-17842');
T('-3', '3');
T('-2', '2');
T('-1.855', '1.855');
T('246866', '-246866');
T('-0.0022', '0.0022');
T('-1', '1');
T('1283', '-1283');
T('2.1', '-2.1');
T('3.289e-12', '-0.000000000003289');
T('-1656', '1656');
T('3.9', '-3.9');
T('1.12', '-1.12');
T('3.54e-16', '-0.000000000000000354');
T('-0.001123', '0.001123');
T('2.06551e-14', '-0.0000000000000206551');
T('-19319.3', '19319.3');
T('3', '-3');
T('-6', '6');
T('5.747e-17', '-0.00000000000000005747');
T('-1.756', '1.756');
T('2.71004e-15', '-0.00000000000000271004');
T('1.4', '-1.4');
T('-0.0000019', '0.00000190');
T('-6', '6');
T('-31.4', '31.4');
T('1', '-1');
T('-39.954', '39.9540');
T('8.4', '-8.40');
T('5.3382e-17', '-0.0000000000000000533820');
T('8.4', '-8.4');
T('-106', '106');
T('905', '-905');
T('-2030.8', '2030.8');
T('0.19358', '-0.193580');
T('50057.4', '-50057.4');
T('8.0731e-15', '-0.0000000000000080731');
T('2.4', '-2.4');
T('-1', '1');
T('0.026038', '-0.026038');
T('-22', '22');
T('-2.8', '2.8');
T('0.00110001', '-0.00110001');
T('7', '-7');
T('-705', '705');
T('-36046', '36046');
T('2.42', '-2.42');
T('-1.225', '1.225');
T('36.8', '-36.8');
T('6.8926', '-6.8926');
T('163575', '-163575');
T('3.29e-16', '-0.000000000000000329');
T('-3.9612e-20', '0.000000000000000000039612');
T('6.3', '-6.3');
T('1.1', '-1.1');
T('-53', '53');
T('-6.3', '6.3');
T('-3.73', '3.73');
T('5.99e-13', '-0.000000000000599');
T('-0.0453', '0.0453');
T('6.2', '-6.2');
T('5', '-5');
T('4.85599e-7', '-0.000000485599');
T('-6.554e-19', '0.0000000000000000006554');
T('245.2', '-245.20');
T('-12.557', '12.557');
T('8.7', '-8.7');
T('-38.7', '38.7');
T('1.1291', '-1.1291');
T('-3', '3');
T('40533.9', '-40533.9');
T('135.1', '-135.1');
T('-213', '213');
T('-271352', '271352');
T('-159.9', '159.9');
T('-103632', '103632');
T('-0.00000225418', '0.00000225418');
T('-2.1e-16', '0.00000000000000021');
T('14.5', '-14.5');
T('48016', '-48016');
T('282', '-282.0');
T('9.3552e-18', '-0.0000000000000000093552');
T('237', '-237');
T('-21.1', '21.1');
T('2.281', '-2.281');
T('-4.68312', '4.68312');
T('7', '-7');
T('6', '-6');
T('5.3', '-5.3');
T('-681.586', '681.586');
T('-1.59e-16', '0.0000000000000001590');
T('-2.94', '2.94');
T('-1', '1');
T('7.03', '-7.03');
T('5.73608e-13', '-0.000000000000573608');
T('2', '-2');
T('-1.26e-18', '0.00000000000000000126');
T('-1.5e-14', '0.000000000000015');
T('2', '-2');
T('-44', '44');
T('-1.3928', '1.3928');
T('18811.4', '-18811.4');
T('6.6', '-6.6');
T('1.99', '-1.99');
T('-6.6496e-14', '0.000000000000066496');
T('27.184', '-27.184');
T('0.00007614', '-0.00007614');
T('5478', '-5478.0');
T('-30.6432', '30.6432');
T('-108', '108');
T('-1', '1');
T('-61', '61');
T('4', '-4');
T('-0.032192', '0.032192');
T('2.6e-8', '-0.000000026');
BigNumber.config({EXPONENTIAL_AT : 0});
T('-5.0600621890668482322956892808849303e+20', '5.0600621890668482322956892808849303e+20');
T('7e+0', '-7e+0');
T('-6.1095374220609e+13', '6.1095374220609e+13');
T('9.01e+2', '-9.01e+2');
T('-1.016984074247269470395836690098169093010136836967e+39', '1.016984074247269470395836690098169093010136836967e+39');
T('-1.497639134680472576e+18', '1.497639134680472576e+18');
T('-4.1717657571404248e+16', '4.1717657571404248e+16');
T('8.983272e+1', '-8.983272e+1');
T('-5.308416e+6', '5.308416e+6');
T('-2.09764e+3', '2.09764e+3');
T('-3.83432050166120236679168e+23', '3.83432050166120236679168e+23');
T('-4.096e+3', '4.096e+3');
T('2.679971527468745095582058350756311201706813294321409e+51', '-2.679971527468745095582058350756311201706813294321409e+51');
T('-5.067853299870089529116832768e+2', '5.067853299870089529116832768e+2');
T('-3.48822062687911109850066182676769e+32', '3.48822062687911109850066182676769e+32');
T('-1e+0', '1e+0');
T('4.2773e+0', '-4.2773e+0');
T('5.8169306081172252508071119604378757744768e+12', '-5.8169306081172252508071119604378757744768e+12');
T('-1e+0', '1e+0');
T('1.51655708279450944384385164853883404204414169862685507e+46', '-1.51655708279450944384385164853883404204414169862685507e+46');
T('-8.1e+1', '8.1e+1');
T('-1.296e+3', '1.296e+3');
T('-2.9e+0', '2.9e+0');
T('-1.764e+3', '1.764e+3');
T('9.3418332730097368870513138581415704704611459349313e+49', '-9.3418332730097368870513138581415704704611459349313e+49');
T('-Infinity', Infinity);
T('-Infinity', 'Infinity');
T('Infinity', -Infinity);
T('Infinity', '-Infinity');
T('NaN', NaN);
T('NaN', 'NaN');
BigNumber.config({EXPONENTIAL_AT : 1e+9});
assert(-1, new BigNumber(2).neg().s);
assert(1, new BigNumber(-2).neg().s);
assert(null, new BigNumber(NaN).neg().s);
assert(null, new BigNumber('-NaN').neg().s);
assert(-1, new BigNumber(Infinity).neg().s);
assert(1, new BigNumber('-Infinity').neg().s);
assert(false, isMinusZero(new BigNumber(1).neg()));
assert(true, isMinusZero(new BigNumber(0).neg()));
assert(true, isMinusZero(new BigNumber(0).neg()));
assert(true, isMinusZero(new BigNumber('0.00000').neg()));
assert(true, isMinusZero(new BigNumber('+0.0').neg()));
assert(false, isMinusZero(new BigNumber(-0).neg()));
assert(false, isMinusZero(new BigNumber('-0').neg()));
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

361
test/others.js Normal file
View File

@ -0,0 +1,361 @@
var count = (function others(BigNumber) {
var start = +new Date(),
log,
error,
n,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
log('\n Testing others...');
/*
*
* isFinite
* isNaN
* isNegative
* isZero
* equals
* greaterThan
* greaterThanOrEqualTo
* lessThan
* lessThanOrEqualTo
* valueOf
*
*/
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
EXPONENTIAL_AT : 1e+9,
RANGE : 1e+9,
ERRORS : true
});
n = new BigNumber(1);
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(true, n.equals(n));
assert(true, n.equals(n, 2));
assert(true, n.equals(1, 3));
assert(true, n.equals(n, 4));
assert(true, n.equals(1, 5));
assert(true, n.equals(n, 6));
assert(true, n.equals(1, 7));
assert(true, n.equals(n, 8));
assert(true, n.equals(1, 9));
assert(true, n.equals(n, 10));
assert(true, n.equals(n, 11));
assert(true, n.equals(1, 12));
assert(true, n.equals(n, 13));
assert(true, n.equals(1, 14));
assert(true, n.equals(n, 15));
assert(true, n.equals(1, 16));
assert(true, n.equals(n, 17));
assert(true, n.equals(1, 18));
assert(true, n.equals(n, 19));
assert(true, n.equals('1.0', 20));
assert(true, n.equals('1.00', 21));
assert(true, n.equals('1.000', 22));
assert(true, n.equals('1.0000', 23));
assert(true, n.equals('1.00000', 24));
assert(true, n.equals('1.000000', 25));
assert(true, n.equals(new BigNumber(1, 10), 26));
assert(true, n.equals(new BigNumber(1), 27));
assert(true, n.equals(1, 28));
assert(true, n.equals(1, 29));
assert(true, n.equals(1, 30));
assert(true, n.equals(1, 31));
assert(true, n.equals(1, 32));
assert(true, n.equals(1, 33));
assert(true, n.equals(1, 34));
assert(true, n.equals(1, 35));
assert(true, n.equals(1, 36));
assert(true, n.greaterThan(0.99999));
assert(false, n.greaterThanOrEqualTo(1.1));
assert(true, n.lessThan(1.001));
assert(true, n.lessThanOrEqualTo(2));
assert(n.toString(), n.valueOf());
n = new BigNumber('-0.1');
assert(true, n.isF());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(false, n.isZ());
assert(false, n.equals(0.1));
assert(false, n.greaterThan(-0.1));
assert(true, n.greaterThanOrEqualTo(-1));
assert(true, n.lessThan(-0.01));
assert(false, n.lessThanOrEqualTo(-1));
assert(n.toString(), n.valueOf());
n = new BigNumber(Infinity);
assert(false, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(true, n.eq('Infinity'));
assert(true, n.eq(1/0));
assert(true, n.gt('9e999'));
assert(true, n.gte(Infinity));
assert(false, n.lt(Infinity));
assert(true, n.lte(Infinity));
assert(n.toString(), n.valueOf());
n = new BigNumber('-Infinity');
assert(false, n.isF());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(false, n.isZ());
assert(false, n.equals(Infinity));
assert(true, n.equals(-1/0));
assert(false, n.greaterThan(-Infinity));
assert(true, n.greaterThanOrEqualTo('-Infinity', 8));
assert(true, n.lessThan(0));
assert(true, n.lessThanOrEqualTo(Infinity));
assert(n.toString(), n.valueOf());
n = new BigNumber('0.0000000');
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(true, n.isZero());
assert(true, n.eq(-0));
assert(true, n.gt(-0.000001)); // 81
assert(false, n.gte(0.1));
assert(true, n.lt(0.0001));
assert(true, n.lte(-0));
assert(n.toString(), n.valueOf());
n = new BigNumber(-0);
assert(true, n.isF());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(true, n.isZ());
assert(true, n.equals('0.000'));
assert(true, n.greaterThan(-1));
assert(false, n.greaterThanOrEqualTo(0.1));
assert(false, n.lessThan(0));
assert(false, n.lessThan(0, 36));
assert(true, n.lessThan(0.1));
assert(true, n.lessThanOrEqualTo(0));
assert(n.toString(), n.valueOf());
n = new BigNumber('NaN');
assert(false, n.isFinite());
assert(true, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(false, n.eq(NaN));
assert(false, n.eq(Infinity));
assert(false, n.gt(0));
assert(false, n.gte(0)); // 103
assert(false, n.lt(1));
assert(false, n.lte(-0));
assert(false, n.lte(-1));
assert(n.toString(), n.valueOf());
BigNumber.config({ ERRORS : false });
n = new BigNumber('hiya');
assert(false, n.isFinite());
assert(true, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(false, n.equals(0));
assert(false, n.greaterThan(0));
assert(false, n.greaterThanOrEqualTo(-Infinity));
assert(false, n.lessThan(Infinity));
assert(false, n.lessThanOrEqualTo(0));
assert(n.toString(), n.valueOf());
BigNumber.config({ ERRORS : true });
n = new BigNumber('-1.234e+2');
assert(true, n.isF());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(false, n.isZ());
assert(true, n.eq(-123.4, 10));
assert(true, n.gt('-ff', 16));
assert(true, n.gte('-1.234e+3'));
assert(true, n.lt(-123.39999));
assert(true, n.lte('-123.4e+0'));
assert(n.toString(), n.valueOf());
n = new BigNumber('5e-200');
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(true, n.equals(5e-200));
assert(true, n.greaterThan(5e-201));
assert(false, n.greaterThanOrEqualTo(1));
assert(true, n.lessThan(6e-200));
assert(true, n.lessThanOrEqualTo(5.1e-200));
assert(n.toString(), n.valueOf());
n = new BigNumber('1');
assert(true, n.equals(n));
assert(true, n.equals(n.toS()));
assert(true, n.equals(n.toString()));
assert(true, n.equals(n.valueOf()));
assert(true, n.equals(n.toFixed()));
assert(true, n.equals(1));
assert(true, n.equals('1e+0'));
assert(false, n.equals(-1));
assert(false, n.equals(0.1));
BigNumber.config({ ERRORS : false });
assert(false, new BigNumber(NaN).equals(0));
assert(false, new BigNumber(null).equals(0));
assert(false, new BigNumber(undefined).equals(0));
assert(false, new BigNumber(Infinity).equals(0));
assert(false, new BigNumber([]).equals(0));
assert(false, new BigNumber([]).equals(0));
assert(false, new BigNumber({}).equals(0));
assert(false, new BigNumber('').equals(0));
assert(false, new BigNumber(' ').equals(0));
assert(false, new BigNumber('\t').equals(0));
assert(false, new BigNumber('gerg').equals(0));
assert(false, new BigNumber(new Date).equals(0));
assert(false, new BigNumber(new RegExp).equals(0));
assert(false, new BigNumber(0.1).equals(0));
assert(false, new BigNumber(1e9 + 1).equals(1e9));
assert(false, new BigNumber(1e9 - 1).equals(1e9));
assert(true, new BigNumber(1e9 + 1).equals(1e9 + 1));
assert(true, new BigNumber(1).equals(1));
assert(false, new BigNumber(1).equals(-1));
assert(false, new BigNumber(NaN).equals('efffe'));
assert(false, new BigNumber('b').greaterThan('a'));
assert(false, new BigNumber('a').lessThan('b', 10));
assert(true, new BigNumber('a', 16).lessThanOrEqualTo('ff', 16));
assert(true, new BigNumber('b', 16).greaterThanOrEqualTo(9, 16));
BigNumber.config({ ERRORS : true });
assert(true, new BigNumber(10).greaterThan(10, 2));
assert(true, new BigNumber(10).greaterThan(10, 3));
assert(true, new BigNumber(10).greaterThan(10, 4));
assert(true, new BigNumber(10).greaterThan(10, 5));
assert(true, new BigNumber(10).greaterThan(10, 6));
assert(true, new BigNumber(10).greaterThan(10, 7));
assert(true, new BigNumber(10).greaterThan(10, 8));
assert(true, new BigNumber(10).greaterThan(10, 9));
assert(false, new BigNumber(10).greaterThan(10, 10));
assert(false, new BigNumber(10).greaterThan(10, 11));
assert(false, new BigNumber(10).greaterThan(10, 12));
assert(false, new BigNumber(10).greaterThan(10, 13));
assert(true, new BigNumber(10).lessThan(10, 11));
assert(true, new BigNumber(10).lessThan(10, 12));
assert(true, new BigNumber(10).lessThan(10, 13));
assert(true, new BigNumber(10).lessThan(10, 14));
assert(true, new BigNumber(10).lessThan(10, 15));
assert(true, new BigNumber(10).lessThan(10, 16));
assert(true, new BigNumber(10).lessThan(10, 17));
assert(true, new BigNumber(10).lessThan(10, 18));
assert(true, new BigNumber(10).lessThan(10, 19));
assert(true, new BigNumber(10).lessThan(10, 20));
assert(true, new BigNumber(10).lessThan(10, 21));
assert(true, new BigNumber(10).lessThan(10, 22));
assert(true, new BigNumber(10).lessThan(10, 34));
assert(true, new BigNumber(10).lessThan(10, 35));
assert(true, new BigNumber(10).lessThan(10, 36));
assert(false, new BigNumber(NaN).lessThan(NaN));
assert(false, new BigNumber(Infinity).lessThan(-Infinity));
assert(false, new BigNumber(Infinity).lessThan(Infinity));
assert(true, new BigNumber(Infinity, 10).lessThanOrEqualTo(Infinity, 2));
assert(false, new BigNumber(NaN).greaterThanOrEqualTo(NaN));
assert(true, new BigNumber(Infinity).greaterThanOrEqualTo(Infinity));
assert(true, new BigNumber(Infinity).greaterThanOrEqualTo(-Infinity));
assert(false, new BigNumber(NaN).greaterThanOrEqualTo(-Infinity));
assert(true, new BigNumber(-Infinity).greaterThanOrEqualTo(-Infinity));
assert(false, new BigNumber(2, 10).greaterThan(10, 2));
assert(false, new BigNumber(10, 2).lessThan(2, 10));
assert(true, new BigNumber(255).lessThanOrEqualTo('ff', 16));
assert(true, new BigNumber('a', 16).greaterThanOrEqualTo(9, 16));
assert(false, new BigNumber(0).lessThanOrEqualTo('NaN'));
assert(false, new BigNumber(0).greaterThanOrEqualTo(NaN));
assert(false, new BigNumber(NaN, 2).lessThanOrEqualTo('NaN', 36));
assert(false, new BigNumber(NaN, 36).greaterThanOrEqualTo(NaN, 2));
assert(false, new BigNumber(0).lessThanOrEqualTo(-Infinity));
assert(true, new BigNumber(0).greaterThanOrEqualTo(-Infinity));
assert(true, new BigNumber(0).lessThanOrEqualTo('Infinity', 36));
assert(false, new BigNumber(0).greaterThanOrEqualTo('Infinity', 36));
assert(false, new BigNumber(10).lessThanOrEqualTo(20, 4));
assert(true, new BigNumber(10).lessThanOrEqualTo(20, 5));
assert(false, new BigNumber(10).greaterThanOrEqualTo(20, 6));
assert(false, new BigNumber(1.23001e-2).lessThan(1.23e-2));
assert(true, new BigNumber(1.23e-2).lt(1.23001e-2));
assert(false, new BigNumber(1e-2).lessThan(9.999999e-3));
assert(true, new BigNumber(9.999999e-3).lt(1e-2));
assert(false, new BigNumber(1.23001e+2).lessThan(1.23e+2));
assert(true, new BigNumber(1.23e+2).lt(1.23001e+2));
assert(true, new BigNumber(9.999999e+2).lessThan(1e+3));
assert(false, new BigNumber(1e+3).lt(9.9999999e+2));
assert(false, new BigNumber(1.23001e-2).lessThanOrEqualTo(1.23e-2));
assert(true, new BigNumber(1.23e-2).lte(1.23001e-2));
assert(false, new BigNumber(1e-2).lessThanOrEqualTo(9.999999e-3));
assert(true, new BigNumber(9.999999e-3).lte(1e-2));
assert(false, new BigNumber(1.23001e+2).lessThanOrEqualTo(1.23e+2));
assert(true, new BigNumber(1.23e+2).lte(1.23001e+2));
assert(true, new BigNumber(9.999999e+2).lessThanOrEqualTo(1e+3));
assert(false, new BigNumber(1e+3).lte(9.9999999e+2));
assert(true, new BigNumber(1.23001e-2).greaterThan(1.23e-2));
assert(false, new BigNumber(1.23e-2).gt(1.23001e-2));
assert(true, new BigNumber(1e-2).greaterThan(9.999999e-3));
assert(false, new BigNumber(9.999999e-3).gt(1e-2));
assert(true, new BigNumber(1.23001e+2).greaterThan(1.23e+2));
assert(false, new BigNumber(1.23e+2).gt(1.23001e+2));
assert(false, new BigNumber(9.999999e+2).greaterThan(1e+3));
assert(true, new BigNumber(1e+3).gt(9.9999999e+2));
assert(true, new BigNumber(1.23001e-2).greaterThanOrEqualTo(1.23e-2));
assert(false, new BigNumber(1.23e-2).gte(1.23001e-2));
assert(true, new BigNumber(1e-2).greaterThanOrEqualTo(9.999999e-3));
assert(false, new BigNumber(9.999999e-3).gte(1e-2));
assert(true, new BigNumber(1.23001e+2).greaterThanOrEqualTo(1.23e+2));
assert(false, new BigNumber(1.23e+2).gte(1.23001e+2));
assert(false, new BigNumber(9.999999e+2).greaterThanOrEqualTo(1e+3));
assert(true, new BigNumber(1e+3).gte(9.9999999e+2));
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

1969
test/plus.js Normal file

File diff suppressed because it is too large Load Diff

1535
test/pow.js Normal file

File diff suppressed because it is too large Load Diff

1416
test/quick-test.js Normal file

File diff suppressed because it is too large Load Diff

2382
test/round.js Normal file

File diff suppressed because it is too large Load Diff

2565
test/sqrt.js Normal file

File diff suppressed because it is too large Load Diff

2218
test/times.js Normal file

File diff suppressed because it is too large Load Diff

845
test/toExponential.js Normal file
View File

@ -0,0 +1,845 @@
var count = (function toExponential(BigNumber) {
var start = +new Date(),
log,
error,
undefined,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
function assertException(func, message) {
var actual;
total++;
try {
func();
} catch (e) {
actual = e;
}
if (actual && actual.name == 'BigNumber Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a BigNumber Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, decimalPlaces){
assert(String(expected), new BigNumber(value).toExponential(decimalPlaces));
}
log('\n Testing toExponential...');
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : true,
RANGE : 1E9,
EXPONENTIAL_AT : 1E9
});
T('1e+0', 1, undefined);
T('1.1e+1', 11, undefined);
T('1.12e+2', 112, undefined);
T('1e+0', 1, 0);
T('1e+1', 11, 0);
T('1e+2', 112, 0);
T('1.0e+0', 1, 1);
T('1.1e+1', 11, 1);
T('1.1e+2', 112, 1);
T('1.00e+0', 1, 2);
T('1.10e+1', 11, 2);
T('1.12e+2', 112, 2);
T('1.000e+0', 1, 3);
T('1.100e+1', 11, 3);
T('1.120e+2', 112, 3);
T('1e-1', 0.1, undefined);
T('1.1e-1', 0.11, undefined);
T('1.12e-1', 0.112, undefined);
T('1e-1', 0.1, 0);
T('1e-1', 0.11, 0);
T('1e-1', 0.112, 0);
T('1.0e-1', 0.1, 1);
T('1.1e-1', 0.11, 1);
T('1.1e-1', 0.112, 1);
T('1.00e-1', 0.1, 2);
T('1.10e-1', 0.11, 2);
T('1.12e-1', 0.112, 2);
T('1.000e-1', 0.1, 3);
T('1.100e-1', 0.11, 3);
T('1.120e-1', 0.112, 3);
T('-1e+0', -1, undefined);
T('-1.1e+1', -11, undefined);
T('-1.12e+2', -112, undefined);
T('-1e+0', -1, 0);
T('-1e+1', -11, 0);
T('-1e+2', -112, 0);
T('-1.0e+0', -1, 1);
T('-1.1e+1', -11, 1);
T('-1.1e+2', -112, 1);
T('-1.00e+0', -1, 2);
T('-1.10e+1', -11, 2);
T('-1.12e+2', -112, 2);
T('-1.000e+0', -1, 3);
T('-1.100e+1', -11, 3);
T('-1.120e+2', -112, 3);
T('-1e-1', -0.1, undefined);
T('-1.1e-1', -0.11, undefined);
T('-1.12e-1', -0.112, undefined);
T('-1e-1', -0.1, 0);
T('-1e-1', -0.11, 0);
T('-1e-1', -0.112, 0);
T('-1.0e-1', -0.1, 1);
T('-1.1e-1', -0.11, 1);
T('-1.1e-1', -0.112, 1);
T('-1.00e-1', -0.1, 2);
T('-1.10e-1', -0.11, 2);
T('-1.12e-1', -0.112, 2);
T('-1.000e-1', -0.1, 3);
T('-1.100e-1', -0.11, 3);
T('-1.120e-1', -0.112, 3);
T('NaN', NaN, undefined);
T('NaN', -NaN, 2);
T('Infinity', Infinity, undefined);
T('Infinity', Infinity, 10);
T('-Infinity', -Infinity, 0);
T('-Infinity', -Infinity, 1);
T('0e+0', 0, undefined);
T('0e+0', -0, undefined);
T('-5.0e-1', -0.5, 1);
T('0.00e+0', 0, 2);
T('1e+1', 11.2356, 0);
T('1.1236e+1', 11.2356, 4);
T('1.1236e-4', 0.000112356, 4);
T('-1.1236e-4', -0.000112356, 4);
T('1.12356e-4', 0.000112356, undefined);
T('-1.12356e-4', -0.000112356, undefined);
T('1.00e+0', 0.99976, 2);
T('1.00e+2', 99.9979, 2);
T('1.00e+5', '99991.27839', 2);
T('1.000e+2', '99.999', 3);
T('1.000e+7', '9999512.8', 3);
T('1.00e+9', '999702726', 2);
T('1.000e+3', '999.964717', 3);
BigNumber.config({ROUNDING_MODE : 0});
T('-5.3453435435e+8', '-53453.435435E4', undefined);
T('-8.8254658100092746334967191957167916942544e+17', '-882546581000927463.34967191957167916942543286', 40);
T('-4.794121828559674450610889008537305783490457e-9', '-0.00000000479412182855967445061088900853730578349045628396662493370334888944406719979291547717079', 42);
T('3.6149e+33', '3614844933096444884855774574994631.0106397808', 4);
T('5.582954000000000e-12', '0.000000000005582954', 15);
T('-3.88740271991885914774802363151163005925700000000000000000e-24', '-0.000000000000000000000003887402719918859147748023631511630059257', 56);
T('-6.87079645872437277236913190316306435274902613151676421e-20', '-0.00000000000000000006870796458724372772369131903163064352749026131516764202733298056929060151437', 53);
T('3.8181874087278104533737313621586530711155405443818235503358935045749888900678e+35', '381818740872781045337373136215865307.11155405443818235503358935045749888900677769535371296063', 76);
T('-7.11375441247784115059912118586189732891550e+20', '-711375441247784115059.91211858618973289154952986', 41);
T('6.5783e+24', '6578282366667302135641813.7249573246362582', 4);
T('6.000000000000000000000e-20', '0.00000000000000000006', 21);
T('-5.3799672107777e+13', '-53799672107777', 13);
T('-6.949e-23', '-0.00000000000000000000006948849870723', 3);
T('-8.073585184316705309757817e+25', '-80735851843167053097578169.623098209399637950843019109979317', 24);
T('-4.2956483e-12', '-0.0000000000042956482047751', 7);
T('-6.1162155721951440801240154580459651167830311633e+15', '-6116215572195144.0801240154580459651167830311633', 46);
T('-7.263265230767e-21', '-0.000000000000000000007263265230766073544739', 12);
T('-2.3013406115701776345891815e+18', '-2301340611570177634.5891814408272260224632', 25);
T('-6.0299793663e+30', '-6029979366232747481609455093247.705001183386474', 10);
T('-2.97544304967e+21', '-2975443049668038511693.75547178021412', 11);
T('-4.1471192639160032e+10', '-41471192639.1600315953295208128538183546', 16);
T('-3.61201776785294987e+27', '-3612017767852949869824542721.1595027189', 17);
T('-6.9983494044506115115e+17', '-699834940445061151.14676', 19);
T('-1.4580700323629245038287e+20', '-145807003236292450382.86958174', 22);
T('-8.54e+10', '-85390930743', 2);
T('-2.715269856970717e+19', '-27152698569707163435', 15);
T('-5.67681004e+20', '-567681003999187989540.627303416332508226276308449233', 8);
T('-2.06809e+27', '-2068085084336615438842661921.06985539576218546524301', 5);
T('-2.92273061370427012250925e+14', '-292273061370427.0122509240087955481845060858420928631', 23);
T('-4.3355e-17', '-0.0000000000000000433542', 4);
T('-3.491610942584e+21', '-3491610942583064798345', 12);
T('-8.701944635985129980360621e+16', '-87019446359851299.8036062002728328', 24);
T('-4.9e-10', '-0.000000000486409475991', 1);
T('-4.82125e+19', '-48212433366063403866', 5);
T('-7.95593941e-20', '-0.000000000000000000079559394098236', 8);
T('-2.00563e-10', '-0.0000000002005622924388', 5);
T('-6.9777057921142634382521825e+16', '-69777057921142634.3825218243275152606161149381', 25);
T('-8.42591e+14', '-842590769172062', 5);
T('-6.35123264409e+27', '-6351232644080754054285724566', 11);
T('-5.508835492577586495894259979e-28', '-0.00000000000000000000000000055088354925775864958942599785412', 27);
T('-2.667451876e+12', '-2667451875964', 9);
T('-6.6444610474323616283e+26', '-664446104743236162820999716', 19);
T('-2.419775049243e+12', '-2419775049242.726', 12);
T('-5.32e-18', '-0.000000000000000005319', 2);
T('-8.63030355223e-26', '-0.000000000000000000000000086303035522286938593814060049934', 11);
T('-2.5046920981956385048538613818080285657602718e+17', '-250469209819563850.48538613818080285657602717018', 43);
T('-3.78e+15', '-3779392491464393.04412843034387404882622864039', 2);
T('-3.3883802002818774e-21', '-0.0000000000000000000033883802002818773261717', 16);
T('-3.57205e+19', '-35720468100481047658.74549510716', 5);
T('-5.23810604e+18', '-5238106039196464333.4164490675655417554216049', 8);
T('-8.9851705212202749156714435676788925065e+21', '-8985170521220274915671.443567678892506483244', 37);
T('-4.8002620797467441513113e+15', '-4800262079746744.151311270846595944560084461404058322669896', 22);
T('-7.6602835119619761973713784765241687426415076035234065319212e+19', '-76602835119619761973.713784765241687426415076035234065319212', 58);
T('-5.381812197644510770977641728943e+29', '-538181219764451077097764172894.2045958494', 30);
T('-6.04171e+30', '-6041702557251805571827972925970.859227', 5);
T('-3.995516696587253269e+28', '-39955166965872532681529528721.070757896455736015403', 18);
T('-7.597966e+15', '-7597965080819292', 6);
T('-5.302339e+10', '-53023381796.8478', 6);
T('-9.02545540564356e+13', '-90254554056435.587103358700012', 14);
T('-4.90010261765297775855e+21', '-4900102617652977758549.72018756787751358174277326416937', 20);
T('-5.078904359675664732215233579164e+14', '-507890435967566.473221523357916309238214', 30);
T('-5.521012629302366870801695374639196986679745208450805993e+22', '-55210126293023668708016.9537463919698667974520845080599201807', 54);
T('-5.2937835496774926e-19', '-0.00000000000000000052937835496774925027979577384249493104941', 16);
T('-2.3554653675126963e+18', '-2355465367512696228', 16);
T('-2.891052510655698093e-17', '-0.000000000000000028910525106556980924149216708779185331', 18);
T('-3.68377e-16', '-0.0000000000000003683765961604816288244373051', 5);
T('-3.95708e+25', '-39570783738574043219687566.965221194063889914', 5);
T('-3.584456985168021826814122e-17', '-0.0000000000000000358445698516802182681412158196413726', 24);
T('-8.556316744104688591686120874555554808035e+28', '-85563167441046885916861208745.55554808034964', 39);
T('-6.02219e+18', '-6022186164465021650.884475588', 5);
T('-7.790612428288e+18', '-7790612428287383595.5394047', 12);
BigNumber.config({ROUNDING_MODE : 1});
T('0e+0', '-0.0E-0', undefined);
T('-2.856376815219143184897347685012382222462687620998915470135915e+6', '-2856376.815219143184897347685012382222462687620998915470135915511363444', 60);
T('7.75700e-24', '0.000000000000000000000007757', 5);
T('7.0e-1', '0.7', 1);
T('5.2109749078977455423107465583658126e+37', '52109749078977455423107465583658126637', 34);
T('3.631093819552528994444977110063007461579154042777868294000e-29', '0.00000000000000000000000000003631093819552528994444977110063007461579154042777868294', 57);
T('-9.893937860425888e+8', '-989393786.042588804219191', 15);
T('8.7978043622607467e+42', '8797804362260746751563912625017414439944006.5804807', 16);
T('-4.6561702764394602621e-7', '-0.000000465617027643946026213823955447791862428108248596086901464075785390015', 19);
T('-2.542770482242902215596924884302407e+8', '-254277048.224290221559692488430240765024783', 33);
T('2.70000000e-8', '0.000000027', 8);
T('-8.0291821891769794408790934252924453237e+16', '-80291821891769794.408790934252924453237503615825249362166', 37);
T('-8.05295923004057358545854771e-16', '-0.0000000000000008052959230040573585458547716514262', 26);
T('-2.786758e-21', '-0.00000000000000000000278675879025858093817787290334306', 6);
T('-8.0160835624737225803853824687641777660406527e+20', '-801608356247372258038.538246876417776604065270622886204812876', 43);
T('-7.2849054887999144694619191770897589e+27', '-7284905488799914469461919177.08975892527524', 34);
T('-7.586e-17', '-0.00000000000000007586908', 3);
T('-5.9508150933636580674249602941673984254864e+20', '-595081509336365806742.496029416739842548642249', 40);
T('-3.526911897e-18', '-0.000000000000000003526911897770082481187', 9);
T('-5.774e-22', '-0.0000000000000000000005774729035676859', 3);
T('-6.4700957007714124190210074e-13', '-0.00000000000064700957007714124190210074383', 25);
T('-5.610492e+21', '-5610492566512449795573', 6);
T('-6.015e+23', '-601556443593022914280678', 3);
T('-6.0673361553344e+11', '-606733615533.448288878', 13);
T('-3.1e+26', '-315617199368461055533962323.071668327669249', 1);
T('-9.1391079512104562032343e+24', '-9139107951210456203234346', 22);
T('-2.0441e+21', '-2044198307917443182711', 4);
T('-8.21283723216249535240085606500821783973097233e+23', '-821283723216249535240085.606500821783973097233814324', 44);
T('-6.375e+14', '-637540984314799.4', 3);
T('-2.17797482005219478530856429744726e+29', '-217797482005219478530856429744.7268928676963181', 32);
T('-3.9547e+11', '-395476721391', 4);
T('-6.8927e+21', '-6892798573971046301111', 4);
T('-6.33842141402916538926e-12', '-0.000000000006338421414029165389261335065112712777', 20);
T('-4.5727e-30', '-0.000000000000000000000000000004572725511159166', 4);
T('-7.8847457779026882221249217577974e-17', '-0.000000000000000078847457779026882221249217577974', 31);
T('-2.64916231640264927e+12', '-2649162316402.649271824', 17);
T('-1.73604404e+28', '-17360440496948254515028685124.37795415803082546457797184294', 8);
T('-8.680224985623e+16', '-86802249856236148.11694273469092873', 12);
T('-4.3e-19', '-0.00000000000000000043859841576346037715462713764211635', 1);
T('-7.68867535389098159141717105e-11', '-0.000000000076886753538909815914171710501337139', 26);
T('-5.24325038611090505928389422325001606e+21', '-5243250386110905059283.894223250016067979080420266', 35);
T('-1.38e-21', '-0.0000000000000000000013874592057586367688528204069850262406', 2);
T('-7.308601949094508589445770582074109410615037e+24', '-7308601949094508589445770.5820741094106150373221910779', 42);
T('-3.2638e+13', '-32638405387645.3309565877781780222317335852159983', 4);
T('-3.55454737448094719019291183206515059962378e+22', '-35545473744809471901929.118320651505996237856336054914', 41);
T('-5.3906242252792e-11', '-0.00000000005390624225279268530907215395611', 13);
T('-8.86760873811213105078e+15', '-8867608738112131.050787', 20);
T('-4.78129254835567e-23', '-0.00000000000000000000004781292548355671480462711435866243551', 14);
T('-6.4694208834502691835879021438795583630205e-19', '-0.00000000000000000064694208834502691835879021438795583630205', 40);
T('-9.324e-25', '-0.00000000000000000000000093242969', 3);
T('-6.922220589076408182786e+19', '-69222205890764081827.8655148459740694252038421', 21);
T('-4.193207546161458e+19', '-41932075461614585862.215078', 15);
T('-7.98e+20', '-798827417648620333729.80696458197', 2);
T('-2.53e-27', '-0.0000000000000000000000000025361014542495516754818606153', 2);
T('-1.4930677606201e-20', '-0.0000000000000000000149306776062013560263804', 13);
T('-2.4385708957357e+19', '-24385708957357294486.03887038886025345320045340124898971786', 13);
T('-2.3170650157672525597815028610843e+18', '-2317065015767252559.781502861084367708776250552', 31);
T('-6.9178198e+18', '-6917819884210952360.76327902290237387108459707859893972', 7);
T('-5.8557793e-24', '-0.000000000000000000000005855779377', 7);
T('-2.9760848e-12', '-0.00000000000297608486674725722', 7);
T('-5.994209456542723342157e+23', '-599420945654272334215750.2697081334512770109182770472941827', 21);
T('-2.176318765141873189550724e+24', '-2176318765141873189550724', 24);
T('-3.015068240172763167642991583362591462e+17', '-301506824017276316.76429915833625914624', 36);
T('-4.092360120459492827213341546580282588568024330771e+25', '-40923601204594928272133415.465802825885680243307714368088538', 48);
T('-1.241037736e-28', '-0.00000000000000000000000000012410377364', 9);
BigNumber.config({ROUNDING_MODE : 2});
T('0e+0', '0E0000000000', undefined);
T('0e+0', '-0E01', undefined);
T('0.00e+0', '-0E00000000001', 2);
T('3.0465655253692145345165166442116e-14', '0.0000000000000304656552536921453451651664421156', 31);
T('9.0573943842008592406279608542923313381394286641978907203396551e+22', '90573943842008592406279.60854292331338139428664197890720339655043720040907662489784', 61);
T('-1.17181502970008783734855040984899000e-1', '-0.117181502970008783734855040984899', 35);
T('-5.28860565e-16', '-0.00000000000000052886056528317233012115396784629214632', 8);
T('6.4114675970838738000e-18', '0.0000000000000000064114675970838738', 19);
T('8.00000000000000000000e-20', '0.00000000000000000008', 20);
T('2.74000064578288771723078597711103520450391668117802304078152085625023633681179e+24', '2740000645782887717230785.977111035204503916681178023040781520856250236336811781347278', 77);
T('8.1936742669491704846805837777816457628e-16', '0.00000000000000081936742669491704846805837777816457628', 37);
T('-7.2157448e+14', '-721574484716710.00141299844961546', 7);
T('-5.321807464703650000000e-15', '-0.00000000000000532180746470365', 21);
T('-4.449e+27', '-4449471658582621135143349142.228707647170080816912435271162', 3);
T('-4.922915821313919623758e+19', '-49229158213139196237.584', 21);
T('-6.996668225774098e-14', '-0.000000000000069966682257740984029052', 15);
T('-8.6856039174822133942616012424795168e+11', '-868560391748.2213394261601242479516861829472792', 34);
T('-8.461e+21', '-8461810373307862460504', 3);
T('-3.898716627703194625824411967e+25', '-38987166277031946258244119.67718', 27);
T('-2.821935496755e+26', '-282193549675582402670759843.23655', 12);
T('-3.49e-22', '-0.0000000000000000000003491662482987', 2);
T('-3.362111778576231615366457333e-14', '-0.0000000000000336211177857623161536645733316587527475522615', 27);
T('-5.9933e-13', '-0.00000000000059933412636903331', 4);
T('-2.77927721e+29', '-277927721100404435781172100113.4136636412460458083951', 8);
T('-1.876833722329e-10', '-0.0000000001876833722329987477942', 12);
T('-6.5e+14', '-653341175209856', 1);
T('-8.627291840173867961e+14', '-862729184017386.7961', 18);
T('-3.9137457165597668391301218029e-11', '-0.00000000003913745716559766839130121802935022889', 28);
T('-8.95e+10', '-89532775488', 2);
T('-2.1395541875015568986238e-17', '-0.000000000000000021395541875015568986238771696', 22);
T('-4.98575853353890809143399546448630559732119628e-12', '-0.00000000000498575853353890809143399546448630559732119628509', 44);
T('-8.99e+16', '-89989591559494822', 2);
T('-3.49346327e+22', '-34934632714180035424463', 8);
T('-3.5699537605753905457597e-14', '-0.00000000000003569953760575390545759785014980652333323889116', 22);
T('-2.9892536880349975618286e+12', '-2989253688034.9975618286212199904979534461637613', 22);
T('-3.04383919217904949618e+10', '-30438391921.790494961888803732171', 20);
T('-8.232411544e+17', '-823241154405701456', 9);
T('-5.809151226990464016815e-16', '-0.00000000000000058091512269904640168152354', 21);
T('-8.522042397326932431e+13', '-85220423973269.324312660179132118', 18);
T('-7.5210942e-22', '-0.000000000000000000000752109428925015', 7);
T('-5.2018321449543e+23', '-520183214495439298725191.09', 13);
T('-6.04084045453711395629268198016245611021901815e+21', '-6040840454537113956292.68198016245611021901815486929628647', 44);
T('-1.495478178996755138125934544343674798e-13', '-0.00000000000014954781789967551381259345443436747983317353423', 36);
T('-6.881484497510733524151245220630282259985306546537e+16', '-68814844975107335.241512452206302822599853065465371507616758', 48);
T('-4.7121389019956e-14', '-0.00000000000004712138901995619', 13);
T('-8.8332728504053108443425344711e-15', '-0.00000000000000883327285040531084434253447119282', 28);
T('-8.2e+14', '-822000812447305', 1);
T('-7.772164697477093877214551050634072755e+21', '-7772164697477093877214.55105063407275517068350805', 36);
T('-3.9087122838427126623505550357872e+10', '-39087122838.4271266235055503578721071128', 31);
T('-2.312032777966762704192668904908578897e+20', '-231203277796676270419.266890490857889726891117', 36);
T('-6.145717261905789834140342e+10', '-61457172619.0578983414034269108488849155084479', 24);
T('-1.22122395777234009028954105999904e+23', '-122122395777234009028954.10599990431', 32);
T('-8.11092557e-19', '-0.000000000000000000811092557221182808185409783', 8);
T('-2.0148183904e+12', '-2014818390421', 10);
T('-8.5895e+12', '-8589543094837', 4);
T('-4.52948430169449249063e+13', '-45294843016944.92490631367483828208567689248', 20);
T('-5.5627328016242253171e+18', '-5562732801624225317.15482034912', 19);
T('-2.299e+22', '-22994771657263381474221.8393766046648504992', 3);
T('-4.886104291748549e+15', '-4886104291748549.177', 15);
T('-3.7192656464776e-11', '-0.00000000003719265646477604172611', 13);
T('-6.135956620537e+25', '-61359566205370067856449153.5', 12);
T('-3.35703853285800120218674208960269655701e-14', '-0.000000000000033570385328580012021867420896026965570155917', 38);
T('-8.713884178791321311224703e+22', '-87138841787913213112247.03564225163096', 24);
T('-7.073358e+12', '-7073358766762', 6);
T('-6.829e+30', '-6829360758600890577632541121747.862424035', 3);
T('-3.05687463293e+22', '-30568746329329110731433.300963185825462157574537899186', 11);
T('-8.761781e+24', '-8761781624975891699172893.0141633817001124644', 6);
T('-1.477e+12', '-1477134517234.0307742', 3);
T('-5.78904078729758522168774487851811e+16', '-57890407872975852.216877448785181168776187771353947582', 32);
T('-7.74939714942520320266429137e+12', '-7749397149425.20320266429137053013', 26);
T('-8.3224649681672648581370532515e-14', '-0.00000000000008322464968167264858137053251586527433370546682', 28);
T('-7.04146154016765195683657078079536e-22', '-0.000000000000000000000704146154016765195683657078079536', 32);
T('-1.914289454756549529781861916925090389e+16', '-19142894547565495.29781861916925090389840210707205', 36);
T('-8.840670154325523051759462672e+27', '-8840670154325523051759462672.142803216', 27);
T('-2.823e-11', '-0.00000000002823852806134378210195515771768582269146178698', 3);
T('-1.5186417607496557534159723950506e+29', '-151864176074965575341597239505.06547275781526923', 31);
T('-7.397218e+16', '-73972184449181471.152912157', 6);
T('-3.581193819284374099989e+22', '-35811938192843740999895.1573225646377886389016478830802218237', 21);
T('-4.563585432210043885759681337791545e+29', '-456358543221004388575968133779.154510217739887576756399', 33);
T('-1.8176465832459836335875e-18', '-0.0000000000000000018176465832459836335875559', 22);
T('-3.784854627631e+20', '-378485462763141736445.9462626829154663', 12);
T('-3.8510536744200399243363367786406618e+23', '-385105367442003992433633.6778640661831754293129488068676868', 34);
T('-8.7323e+22', '-87323916569164596208111.88101028771355420576029037973', 4);
T('-7.578e+11', '-757882758255.76', 3);
T('-8.5977102122033e+20', '-859771021220338061040.041580289025031', 13);
T('-7.3998697893908579137880913e+17', '-739986978939085791.37880913509684330685', 25);
T('-6.71117252123290052432148305375254e-19', '-0.00000000000000000067111725212329005243214830537525418', 32);
T('-6.6762993760195471322427204620426381935201299178096e+11', '-667629937601.9547132242720462042638193520129917809665', 49);
T('-2.852022020015364818597602e+15', '-2852022020015364.818597602673413917443', 24);
T('-3.151044e+30', '-3151044929117854676102403114231.56823295246', 6);
T('-4.47120537692951873038916592e+10', '-44712053769.29518730389165927694', 26);
T('-7.4041969e+23', '-740419699691346150775964.049522110341852844412207474667958', 7);
T('-6.311838e-10', '-0.000000000631183849892543191', 6);
T('-7.2570104326587672213e+16', '-72570104326587672.213076838263780308795144628367752', 19);
T('-4.445769230869049803541e+15', '-4445769230869049.80354196820931591782233498498378174385', 21);
BigNumber.config({ROUNDING_MODE : 3});
T('-9.99999999000000009e+8', '-999999999.000000009e-0', undefined);
T('-3.99764422903251220452704763278376060858663250289320247532595e+24', '-3997644229032512204527047.63278376060858663250289320247532594416986984981431156065660613', 59);
T('5.534083545686157907280686578717428772e+12', '5534083545686.157907280686578717428772', 36);
T('5.00000000e-9', '0.000000005', 8);
T('-4.08363116583051e+14', '-408363116583051', 14);
T('9.278230415634296945273818e+19', '92782304156342969452.738186255580532649103987374718221928871873054827841260470670536425', 24);
T('-1.08732508998603085454662e-12', '-0.000000000001087325089986030854546619968259691229662152159029641023997866843605032534351388775075', 23);
T('3.5288804517377606688698e+32', '352888045173776066886981811418233.218955856086', 22);
T('4.32188781438877554e+16', '43218878143887755.42593887518334667202', 17);
T('-8.15e+2', '-815', 2);
T('1.515077312590223222678749527e+18', '1515077312590223222.678749527895871363186918977679783240817218232896076765321818445939718165', 27);
T('-8.0538186421664536509917032729912932814374102e+20', '-805381864216645365099.17032729912932814374101821', 43);
T('-3.4367097301002099047381e+14', '-343670973010020.990473804391071456587732173', 22);
T('-5.3421e-12', '-0.0000000000053420288504', 4);
T('-2.6320052e+23', '-263200517731973006983184.60341959097016190770542276', 7);
T('-4.5e-11', '-0.000000000044673422483', 1);
T('-7.232463101115829118145025733451801e-17', '-0.00000000000000007232463101115829118145025733451800457178', 33);
T('-1.18320100044154762448545914170978206041022039e+22', '-11832010004415476244854.5914170978206041022038489', 44);
T('-7.745237371276392645711e+21', '-7745237371276392645710.0521930569226728841707200771', 21);
T('-4.431559500053255695643e-10', '-0.000000000443155950005325569564213010993378905', 21);
T('-2.5e-24', '-0.000000000000000000000002443', 1);
T('-5.005027028439023958391203127005503621542e-11', '-0.0000000000500502702843902395839120312700550362154137', 39);
T('-6.453525377934213334367e-22', '-0.00000000000000000000064535253779342133343665123283565', 21);
T('-4.5594370326121718626850982373529e+13', '-45594370326121.71862685098237352845979966987', 31);
T('-1.709e+16', '-17088248121660259', 3);
T('-3.9047581533864713e+16', '-39047581533864712.6574405', 16);
T('-2.08804202e-17', '-0.000000000000000020880420127397564274443250271135', 8);
T('-6.801694635944774655689008216925036e+15', '-6801694635944774.65568900821692503508025', 33);
T('-8.7691286374104240967931800593734e+19', '-87691286374104240967.93180059373367907299683816381677816389', 31);
T('-2.802257731715238453e-29', '-0.000000000000000000000000000028022577317152384526775320012', 18);
T('-4.4705e+22', '-44704405768781565005877.813010169083', 4);
T('-4.17374908496486449232e-10', '-0.00000000041737490849648644923105632500267064', 20);
T('-2.2707e-10', '-0.00000000022706134122862417334386435', 4);
T('-2.85432e-24', '-0.0000000000000000000000028543100839983854161', 5);
T('-5.79188949e+12', '-5791889489461.643555240257', 8);
T('-7.46e+15', '-7459701910718662.03421293892346992893463534702', 2);
T('-1.0535086280629e+25', '-10535086280628995915087428.2423609320023833125322801559606', 13);
T('-2.9074412651647188367106e+30', '-2907441265164718836710598468491.31550321772', 22);
T('-5.010945976711327691649e+27', '-5010945976711327691648509517.2305', 21);
T('-8.8633960213386533e-20', '-0.0000000000000000000886339602133865324283362544', 16);
T('-3.1891844834898211661452730714015664837805e+19', '-31891844834898211661.45273071401566483780434051217', 40);
T('-5.083380976014365533843229882526437e+28', '-50833809760143655338432298825.264367948359', 33);
T('-6.8e-16', '-0.000000000000000678534987604148025611184', 1);
T('-7.9e+30', '-7838656097386639584904346062976.9346038436', 1);
T('-6.30535781e+20', '-630535780834495012856', 8);
T('-9.663e-30', '-0.00000000000000000000000000000966289400023904753107633012', 3);
T('-2.315198482309e+12', '-2315198482308.7361348', 12);
T('-8.158235289416e+18', '-8158235289415958939', 12);
T('-4.1618890517404316933699206360639988582832624525e+23', '-416188905174043169336992.063606399885828326245241437', 46);
T('-5.97550716981833990839441709632e+21', '-5975507169818339908394.41709631281058258352209', 29);
T('-6.3372e-18', '-0.000000000000000006337122571683959413228', 4);
T('-8.9189088e+18', '-8918908714500548003.38400978696756078013348', 7);
T('-2.30738494e+15', '-2307384939629592.5507643557167543121437', 8);
T('-5.5187220703008771818558364e+20', '-551872207030087718185.58363308126401300424', 25);
T('-6.6221540532808e+16', '-66221540532807215', 13);
T('-7.52280140768218860970644149216497725e+28', '-75228014076821886097064414921.6497724655', 35);
T('-4.50815289e-10', '-0.0000000004508152886241127131780051700309401', 8);
T('-8.05636473909e+28', '-80563647390897795982047004786.9809587987299506647489380735', 11);
T('-8.3e-22', '-0.00000000000000000000082867896643314771124884886449603747139', 1);
T('-8.3783e+13', '-83782644902152', 4);
T('-1.1939712427296807e+16', '-11939712427296807', 16);
T('-6.520492185955083727143468903725e+24', '-6520492185955083727143468.90372469799639', 30);
T('-5.468441290352576854e+22', '-54684412903525768532358.76123265640787599117379', 18);
T('-6.3213239044187e-12', '-0.000000000006321323904418628', 13);
T('-6.80758136e+10', '-68075813559.812083737218313494618879237157412', 8);
T('-2.32394435705096500766e+20', '-232394435705096500765.423311444507670516532857314906', 20);
T('-5.35396744204815374979010975360864002355e+14', '-535396744204815.374979010975360864002354465685768494008245896', 38);
T('-1.8388340153656061115e-24', '-0.0000000000000000000000018388340153656061114681', 19);
T('-2.09349812455746e+24', '-2093498124557455120865520.476275227', 14);
T('-2.888450139093515656e-25', '-0.0000000000000000000000002888450139093515656', 18);
T('-6.97756838052316890676e+30', '-6977568380523168906759075718628.73360426401485819654038588804', 20);
T('-8.05604538646883624239398132377048820023e+24', '-8056045386468836242393981.323770488200227820839', 38);
T('-4.13045948e+29', '-413045947014551860341804907208.7067642881758676', 8);
T('-7.990552461602111454165337515e+23', '-799055246160211145416533.75144940262265224221931', 27);
T('-7.84498851993324e+11', '-784498851993.323271787115869178093231451893938531755482687806', 14);
T('-8.63875584973951951712658379e-21', '-0.000000000000000000008638755849739519517126583785754757065', 26);
T('-8.61609302272300237447639006834635e-14', '-0.00000000000008616093022723002374476390068346342187746', 32);
T('-7.01300801762e+17', '-701300801761204790.177590913310762', 11);
T('-8.0318131135482342451545e-11', '-0.0000000000803181311354823424515442372680533', 22);
T('-8.310034087753417316659936093943321e+25', '-83100340877534173166599360.9394332099174859', 33);
T('-7.716088095718838665380730070082633435173897567e+30', '-7716088095718838665380730070082.6334351738975662966', 45);
T('-6.5207000918869e-14', '-0.00000000000006520700091886862177', 13);
T('-6.579884485936605389e+14', '-657988448593660.538847871', 18);
T('-5.31961604251455760419e+30', '-5319616042514557604183392605338.36600372994596807972708', 20);
T('-7.87765329352729e+16', '-78776532935272856.77806', 14);
T('-8.23e+11', '-822427564609', 2);
T('-1.2946e+16', '-12945401038582508.297183225785515084520662225', 4);
T('-4.3885535805231634787626423119240512694696e+14', '-438855358052316.347876264231192405126946952', 40);
T('-6.4067449547192616381924351e-29', '-0.00000000000000000000000000006406744954719261638192435066816', 25);
T('-9.41834953e+18', '-9418349527156084224.2', 8);
T('-3.19716162829318952418046452988e+13', '-31971616282931.895241804645298754890905582545633', 29);
BigNumber.config({ROUNDING_MODE : 4});
T('-5.002239116605888927178702930656e-39', '-0.00000000000000000000000000000000000000500223911660588892717870293065633642', 30);
T('-8.52292947230244775435e+29', '-852292947230244775434968241532.494643593912804433318745222587246680109833509655450267792446', 20);
T('-6.1169514510867e+10', '-61169514510.8673382', 13);
T('-8.05745763527307676170759722175169266017831695215e+48', '-8057457635273076761707597221751692660178316952146', 47);
T('-4.923572102098e+10', '-49235721020.9847017846898652687600227388412980598816', 12);
T('-7.981341661715027117746906076515945e+41', '-798134166171502711774690607651594491039629', 33);
T('-8.00e-3', '-0.008', 2);
T('8.517466793430899278197016892000000000000e-15', '0.000000000000008517466793430899278197016892', 39);
T('-3.032293512e+0', '-3.0322935124071923328711934463341802038', 9);
T('-2.60682904403489305678908771323995810138267385200000000e-20', '-0.00000000000000000002606829044034893056789087713239958101382673852', 53);
T('-3.935816927273980e+20', '-393581692727398036652.850960055902271', 15);
T('-2.98297216346e-27', '-0.00000000000000000000000000298297216346039288935575576076143', 11);
T('-3.01319315e+23', '-301319315398414808376087.572306433', 8);
T('-8.870698526921188e-12', '-0.00000000000887069852692118832284144110732', 15);
T('-3.27e+23', '-326739927744903524706793.652546266488323001284674736489440831', 2);
T('-8.614e+12', '-8613828413581', 3);
T('-6.1382445990593346026804e+12', '-6138244599059.3346026803630253203', 22);
T('-7.9111971e+12', '-7911197130975', 7);
T('-8.5902152501051e+29', '-859021525010507210136559039003.689834129033952321238', 13);
T('-7.24491e-30', '-0.00000000000000000000000000000724490826045045451271534', 5);
T('-8.4948070285349193974989221504919380656715136165603325e+24', '-8494807028534919397498922.15049193806567151361656033246', 52);
T('-6.3295239596e-17', '-0.00000000000000006329523959626011114164', 10);
T('-3.1725692353e+30', '-3172569235260846783669130724638.711', 10);
T('-4.065727077e+11', '-406572707673.336570352310681187663765', 9);
T('-6.82883869249998075574247223155497e+18', '-6828838692499980755.7424722315549682855987375899188309581152', 32);
T('-2.56144400427045214943786338e+24', '-2561444004270452149437863.38354535663028539', 26);
T('-4.97637439956044400125498868e+23', '-497637439956044400125498.8682100590602459937304614141772', 26);
T('-4.307891929198702822746534506143e+29', '-430789192919870282274653450614.349564081', 30);
T('-8.55e-27', '-0.00000000000000000000000000855367295711812079', 2);
T('-7.906e+11', '-790612526329.410459220189562', 3);
T('-3.1841363e-22', '-0.00000000000000000000031841363', 7);
T('-6.2068049304845006e+20', '-620680493048450055389.3227069760888437941041', 16);
T('-8.4809476e+18', '-8480947614295114807.320148688', 7);
T('-2.287988570734255855e+23', '-228798857073425585542366.399034916953775', 18);
T('-8.148647139762925073276164486240320698e+21', '-8148647139762925073276.1644862403206980851079', 36);
T('-6.87643138785664756e-12', '-0.0000000000068764313878566475604352570287089535238582267443', 17);
T('-3.709587e+18', '-3709586618852569033.55141868', 6);
T('-6.8086794224e+28', '-68086794224433270564431694468.814537646575833889824621540849', 10);
T('-4.966301085179e+19', '-49663010851788946007', 12);
T('-5.34439184068052811184219234494114e+26', '-534439184068052811184219234.494113670484623394', 32);
T('-2.798732412e+16', '-27987324119455299', 9);
T('-1.554430791885961957e+15', '-1554430791885961.956863404519493346081223', 18);
T('-6.90619083822075003978e+24', '-6906190838220750039778836.289105048686876596', 20);
T('-1.108034176809770578315e+12', '-1108034176809.7705783154', 21);
T('-1.43e+22', '-14266566332440117777110.63461224926682073525873105', 2);
T('-9.15e+13', '-91477543307040.916791223', 2);
T('-1.1001e+26', '-110010856476508992391958436.9355559264588205214557001854', 4);
T('-1.2e+16', '-12148027447349021', 1);
T('-4.4e+13', '-44268551660889.40880208546489742632181832780494', 1);
T('-8.62058920338555484081691e+19', '-86205892033855548408.169086865949596390775', 23);
T('-5.2e-13', '-0.00000000000051876025261394172', 1);
T('-4.88063953404884862027221562057786242658496407473e-11', '-0.0000000000488063953404884862027221562057786242658496407473', 47);
T('-5.255e+18', '-5254530327311322805.9528217', 3);
T('-6.4630488003995117e-11', '-0.0000000000646304880039951167486', 16);
T('-3.15214e-23', '-0.00000000000000000000003152137339126187', 5);
T('-8.86563136e+11', '-886563136251.626990531858472111699416852', 8);
T('-8.638990742871e-16', '-0.0000000000000008638990742870608', 12);
T('-1.57817750020560815944470062e+12', '-1578177500205.60815944470062002898187', 26);
T('-3.6558384593093900422637e-27', '-0.00000000000000000000000000365583845930939004226367940618', 22);
T('-7.5e+12', '-7540535487033', 1);
T('-6.7647935206791247e+19', '-67647935206791246567', 16);
T('-3.0204818086245915027e+30', '-3020481808624591502749101182536.872936744534671794', 19);
T('-8.40498662e+12', '-8404986622734.85', 8);
T('-2.944135296894e-18', '-0.0000000000000000029441352968942548971', 12);
T('-8.826099694855290261753e+11', '-882609969485.52902617534731', 21);
T('-1.9717565867734925e-13', '-0.000000000000197175658677349252855292223369', 16);
T('-4.91451975824866130376722e+20', '-491451975824866130376.722358803861287205044883122152013315', 23);
T('-5.111649e+17', '-511164947156144375', 6);
T('-9.496473458673099e+11', '-949647345867.30987953779868637405061', 15);
T('-2.1903308925764762892e+21', '-2190330892576476289225', 19);
T('-3.47598363e+25', '-34759836338593591584288059.755482689269713', 8);
T('-2.9192144584989753156762701431e-24', '-0.0000000000000000000000029192144584989753156762701431', 28);
T('-4.0456517973466503588734928438425e+23', '-404565179734665035887349.28438424933669843', 31);
T('-1.297871549154944904150929e+17', '-129787154915494490.4150929407633398', 24);
T('-1.4566530316908752e+18', '-1456653031690875152.6306667', 16);
T('-3.5521e-12', '-0.00000000000355210483', 4);
T('-9.1838324864110351307221525161e+17', '-918383248641103513.07221525161442', 28);
T('-8.33245633316304149287131334e-22', '-0.00000000000000000000083324563331630414928713133382', 26);
T('-4.593824606634605622464043606094613988489104e+15', '-4593824606634605.62246404360609461398848910424547985108092894', 42);
T('-5.232e-26', '-0.0000000000000000000000000523185958604202852', 3);
T('-3.8319390497954462e+25', '-38319390497954461897251251.444', 16);
T('-1.00157678068191049988073716749599603712e+17', '-100157678068191049.9880737167495996037119953003896147', 38);
T('-4.169977410059689809645035174132294864e+20', '-416997741005968980964.50351741322948635363513285839302', 36);
T('-7.121660153198989278372512656775647e-11', '-0.0000000000712166015319898927837251265677564651728358', 33);
T('-7.98924570545536548623603750084330391943e+19', '-79892457054553654862.360375008433039194317394396964358522', 38);
BigNumber.config({ROUNDING_MODE : 5});
T('4.95474614815842e+38', '495474614815842191683004449862568813538.573064401156', 14);
T('-8.9667567079038139e+16', '-89667567079038139', 16);
T('-7.0e+2', '-703', 1);
T('-2.6249e+33', '-2624861185343559570287214983819906', 4);
T('-6.510119186347371697501169416839709631422185436811698613000000000000000000000000000000e-31', '-0.0000000000000000000000000000006510119186347371697501169416839709631422185436811698613', 84);
T('7.73e+3', '7729', 2);
T('1.4393781011009257793117531801549e+4', '14393.781011009257793117531801548751', 31);
T('8.4e+6', '8404542', 1);
T('8.471284625267663009248667391059202502589207637435209861233007389000000000000000e-35', '0.00000000000000000000000000000000008471284625267663009248667391059202502589207637435209861233007389', 78);
T('-5.26079297227015e+31', '-52607929722701509263909039511536.9266822991', 14);
T('-4.63550600857003551411914120562163394e+15', '-4635506008570035.51411914120562163394396594237358863897062', 35);
T('-7.8219563406482338767189100434751303552919130625101491e+27', '-7821956340648233876718910043.4751303552919130625101491', 52);
T('-6.977184098e+17', '-697718409782854734', 9);
T('-8.1e+15', '-8092701222454628.9934935902179330839653799891168', 1);
T('-3.872944373744596915691884729973e+15', '-3872944373744596.91569188472997336351132980366520033057011287', 30);
T('-1.389676e+11', '-138967565295.146055555208419143848718279114979831585', 6);
T('-2.218316993130903882223e+19', '-22183169931309038822.22612', 21);
T('-3.370809304e-25', '-0.000000000000000000000000337080930401566', 9);
T('-6.1503e+19', '-61503417721509415792.24703', 4);
T('-3.13657134e-22', '-0.00000000000000000000031365713378439345', 8);
T('-1.9e-10', '-0.000000000187981', 1);
T('-2.596508353714425677970049724e+28', '-25965083537144256779700497237.5841327343962292316215149169', 27);
T('-4.151454545748277604112308101174917062e+11', '-415145454574.827760411230810117491706171981266892178', 36);
T('-1.3e-18', '-0.000000000000000001319061308619561567664259803361817', 1);
T('-1.5294854487046553159e+24', '-1529485448704655315921667', 19);
T('-1.9365487654708143765583400538310103350799e-13', '-0.000000000000193654876547081437655834005383101033507988', 40);
T('-3.88128259276357427027515474e+25', '-38812825927635742702751547.353', 26);
T('-5.64525474904155517374289736218e-11', '-0.00000000005645254749041555173742897362182099811344', 29);
T('-8.94963385755006409131430087734467745e+22', '-89496338575500640913143.0087734467744538', 35);
T('-3.7551731901764025e+17', '-375517319017640249', 16);
T('-7.601921e-16', '-0.00000000000000076019214974360137746140339586742455753', 6);
T('-6.93501087055e+20', '-693501087055377288564', 11);
T('-1.283656440009563e+24', '-1283656440009563292695670.575360580373829197017512', 15);
T('-4.9556506e+13', '-49556505932168.7211084603', 7);
T('-8.133584588946e+26', '-813358458894586332533196788.490201803951456991010654609646', 12);
T('-3.824207296e+22', '-38242072955850210158724', 9);
T('-4.2168087e-12', '-0.00000000000421680868317080291', 7);
T('-7.152812829e+15', '-7152812829336253.782723153403637377960530795', 9);
T('-8.0469635248612874571e+16', '-80469635248612874.5712104436', 19);
T('-2.726549954018643349550392804e+11', '-272654995401.8643349550392803783934819148125595437353472547', 27);
T('-2.477986360297097033217143e+30', '-2477986360297097033217143442370.539404', 24);
T('-2.7620555408e+15', '-2762055540757162', 10);
T('-5.044e+10', '-50436788962', 3);
T('-1.51176171306898543927009427965761639e+17', '-151176171306898543.9270094279657616389483779413616294465635', 35);
T('-3.76233131039732974161231568e+13', '-37623313103973.2974161231567776787873083163171', 26);
T('-1.77876313221062362e+17', '-177876313221062362.01', 17);
T('-4.28033364715744300662536e+13', '-42803336471574.430066253616', 23);
T('-6.053e-13', '-0.00000000000060527568964627046163209582', 3);
T('-3.9447068214322315685949701607748761e+16', '-39447068214322315.685949701607748760885392781169754754427622', 34);
T('-4.76203665586552028e+15', '-4762036655865520.285', 17);
T('-7.442141482296791204320219247230530359e+24', '-7442141482296791204320219.2472305303585223494415', 36);
T('-5.96279453376966633e+23', '-596279453376966633175009.6', 17);
T('-3.393419405169789e+24', '-3393419405169788742460001.267', 15);
T('-5.3001e+12', '-5300055380607', 4);
T('-5.6075017651299255742594578e+24', '-5607501765129925574259457.7938331743229', 25);
T('-1.7016332185618e-12', '-0.000000000001701633218561829307163951183908', 13);
T('-8.2586539997288574125e-29', '-0.0000000000000000000000000000825865399972885741250631446', 19);
T('-6.867e+11', '-686673700185', 3);
T('-6.77934398386662123284e+26', '-677934398386662123284378302.457585912', 20);
T('-1.68708254641574159341563239757e+14', '-168708254641574.159341563239757201959', 29);
T('-7.969791397195291274332017902569730510486538e+16', '-79697913971952912.74332017902569730510486538476172', 42);
T('-8.35460490386e+14', '-835460490386401.159749305581999482', 11);
T('-3.4904587e+10', '-34904586685.65531405315150234636', 7);
T('-7.655476116917648649e-10', '-0.0000000007655476116917648649345', 18);
T('-3.035704337e+17', '-303570433749270293', 9);
T('-1.4902739431686400585e-18', '-0.000000000000000001490273943168640058452103113', 19);
T('-2.57617086126164572e+17', '-257617086126164572', 17);
T('-6.9708e+16', '-69708261331391628', 4);
T('-8.61400120130585599610136e-12', '-0.00000000000861400120130585599610136066', 23);
T('-9.0670988886e-19', '-0.000000000000000000906709888862126926', 10);
T('-2.889463982215818248e-26', '-0.00000000000000000000000002889463982215818248', 18);
T('-3.7376459408597195073982491e+26', '-373764594085971950739824910.4572745527', 25);
T('-6.21372353850510695881280108179e-12', '-0.0000000000062137235385051069588128010817907', 29);
T('-2.4240953581712173951958e-21', '-0.00000000000000000000242409535817121739519585', 22);
T('-8.3687559027615173415e+18', '-8368755902761517341.46477685623835786273991', 19);
T('-7.18294352e-11', '-0.0000000000718294352479105', 8);
T('-3.52454012503419773886785e-25', '-0.000000000000000000000000352454012503419773886785342913143', 23);
BigNumber.config({ROUNDING_MODE : 6});
T('-4.3502707501164e+36', '-4350270750116411997402439304498892819', 13);
T('9.5e-21', '0.0000000000000000000094520280724178734152', 1);
T('1.39631186750554172785676012693418617250072200744214625994656047727270672248243741907e+34', '13963118675055417278567601269341861.725007220074421462599465604772727067224824374190703237660781', 83);
T('5.9446570e-26', '0.00000000000000000000000005944657036540768164877637239177740419063920648', 7);
T('7.00000e-12', '0.000000000007', 5);
T('-2.87e+14', '-287060740776209.3950381715', 2);
T('3.411740542875509329e+24', '3411740542875509328514044', 18);
T('-6.20235112738687046118395830000000000000000000000e-29', '-0.000000000000000000000000000062023511273868704611839583', 47);
T('2.94349130121570276626863135396717336528655493e+19', '29434913012157027662.686313539671733652865549279174', 44);
T('4.01255076512828067130306533670644537832e-10', '0.000000000401255076512828067130306533670644537831678294548', 38);
T('-5.4277306444432e+11', '-542773064444.317654960431120452254700391693837992', 13);
T('-4.355706886680889557797360814402e+30', '-4355706886680889557797360814401.536556745674646509159280626', 30);
T('-1.29e-15', '-0.00000000000000128978312277001609181774216296380783932', 2);
T('-1.0588973816292989769e+25', '-10588973816292989768709129.1767038708798755780352204', 19);
T('-3.210569596e+10', '-32105695962.8803639621', 9);
T('-7.18504270173744681360682714959e+28', '-71850427017374468136068271495.87', 29);
T('-4.29794333519778779150824479010034817077204e-10', '-0.0000000004297943335197787791508244790100348170772040392', 41);
T('-4.615682142828269066227773895179987062919e+20', '-461568214282826906622.7773895179987062919071922', 39);
T('-1.3864477517287155526073e+13', '-13864477517287.15552607265', 22);
T('-6.793120028e+13', '-67931200280922.72252141789646787475433427482', 9);
T('-8.075e-18', '-0.000000000000000008074975073002274636799975', 3);
T('-8.360228691054180854419062530687032074820667001e+24', '-8360228691054180854419062.530687032074820667001120752628', 45);
T('-3.0763956760417194035216e-12', '-0.000000000003076395676041719403521594', 22);
T('-2.5288383e+25', '-25288383009460922631988717.84659997837058450749', 7);
T('-4.554185192e+29', '-455418519247311560996997520087.98189', 9);
T('-9.135175372324138467397264e+11', '-913517537232.413846739726417', 24);
T('-8.257259383044471855222900534859251889332388855848e-10', '-0.0000000008257259383044471855222900534859251889332388855848', 48);
T('-7.651597268450922707e-13', '-0.000000000000765159726845092270720405167100094', 18);
T('-8.952011763950994514e+26', '-895201176395099451377549961.34870447', 18);
T('-2.7395479569618982298152060567357e-10', '-0.00000000027395479569618982298152060567357', 31);
T('-1.31151451700453378841431e+24', '-1311514517004533788414313', 23);
T('-5.915297930316863891e-10', '-0.0000000005915297930316863890707686339684395', 18);
T('-1.449e-27', '-0.0000000000000000000000000014487033279693402845128265141859', 3);
T('-3.7e+10', '-36919550406.826974442743517918128', 1);
T('-3.945347688940382499631779106638865e+13', '-39453476889403.824996317791066388653', 33);
T('-8.547704e-29', '-0.0000000000000000000000000000854770378842608635356', 6);
T('-3.76e+25', '-37618296325402619735777629.467812385256281737441412', 2);
T('-8.031066086398624e+28', '-80310660863986235667567286452', 15);
T('-4.038276256088135496e-17', '-0.000000000000000040382762560881354955896694823328777602811', 18);
T('-1.77173574740860868e+25', '-17717357474086086837250852', 17);
T('-1.421967649e+21', '-1421967648805122645888', 9);
T('-4.7e+11', '-469485715327', 1);
T('-7.372223291560455075681748682810527006883e+16', '-73722232915604550.75681748682810527006882666313809409', 39);
T('-8.9539396357e+14', '-895393963565598', 10);
T('-8.14646103854802172250414801405e+10', '-81464610385.48021722504148014045579178726', 29);
T('-1.2053415734425581e+12', '-1205341573442.5581371841633131879', 16);
T('-8.35214176861046133596101313170854966756043001e+28', '-83521417686104613359610131317.0854966756043001041619492', 44);
T('-3.7610694152e-28', '-0.00000000000000000000000000037610694151517628351', 10);
T('-6.71e-12', '-0.00000000000670729337105720320122353', 2);
T('-4.005517304396006251e+13', '-40055173043960.0625088492324182094858', 18);
T('-6.0206e+28', '-60205974155921075891080012488.4566490314762809', 4);
T('-6.36287561326e+11', '-636287561325.9124444291802472', 11);
T('-3.11336117e-16', '-0.000000000000000311336117052129384933053792', 8);
T('-5.3927134886536e+30', '-5392713488653639958906162302264.424436642808', 13);
T('-3.82395446711276e-10', '-0.0000000003823954467112758458806849565215407952986440811', 14);
T('-4.2858082253423e-27', '-0.0000000000000000000000000042858082253422975', 13);
T('-2.9918792622984137284399075479267066e+14', '-299187926229841.3728439907547926706557', 34);
T('-3.1949909651023223034303544498737e+27', '-3194990965102322303430354449.8737', 31);
T('-9.1e-27', '-0.0000000000000000000000000090531861025', 1);
T('-2.8e+11', '-279301037794', 1);
T('-7.126913661498270214611054421e+13', '-71269136614982.70214611054420849', 27);
T('-4.86337579169293342736515180299340135e+13', '-48633757916929.334273651518029934013479777304', 35);
T('-3.406744915848058125e+25', '-34067449158480581246177934.3445612265793', 18);
T('-5.542902272865090080311949446460659235171860088660477e+16', '-55429022728650900.803119494464606592351718600886604770155246', 51);
T('-8.26224854264697737938997145336e+12', '-8262248542646.9773793899714533620028598662842221171', 29);
T('-3.16331e+18', '-3163306186318700887', 5);
T('-9.087531707575372e+25', '-90875317075753723792666377.6466517495', 15);
T('-8.758548512438e+14', '-875854851243824.87435', 12);
T('-3.9e-11', '-0.0000000000387093', 1);
T('-3.987015017148130889206385341736666180313e+11', '-398701501714.813088920638534173666618031251290587', 39);
T('-2.493129998e-11', '-0.00000000002493129997889845697168462', 9);
T('-7.0892393575673871055576e+17', '-708923935756738710.5557595392277447617', 22);
T('-4.931821627225927773384e-20', '-0.00000000000000000004931821627225927773384063578', 21);
T('-5.245261764976094777313893054196562e-17', '-0.0000000000000000524526176497609477731389305419656234', 33);
T('-6.66625797221972034223428591e+23', '-666625797221972034223428.590606426470365', 26);
T('-4.06575860462e+17', '-406575860461750182.91372176567693718', 11);
T('-8.90585675951e+19', '-89058567595113495345', 11);
BigNumber.config({ROUNDING_MODE : 4});
T('-2.033619450856645241153977e+0', '-2.03361945085664524115397653636144859', 24);
T('1.130e+8', '112955590.0430616', 3);
T('-2.1366468193419876852426155614364269e+10', '-21366468193.419876852426155614364269', 34);
T('5.82086615659566151529e+7', '58208661.56595661515285734890860077163', 20);
T('9.1615809372817426111208e+6', '9161580.937281742611120838868847823478250167882379624', 22);
T('3.8976506901061164197e+1', '38.97650690106116419699490320634490920742414', 19);
T('9.0994914931570087194607344641722310104e+6', '9099491.4931570087194607344641722310103895224905', 37);
T('6.06e+5', '605633', 2);
T('2.6999974790473705518992117e+1', '26.9999747904737055189921170044987', 25);
T('6.7108801361722e+6', '6710880.136172156342982663450743452', 13);
T('-8.0e+0', '-8', 1);
T('3.000e-2', '0.03', 3);
T('-4.7e+2', '-469', 1);
T('-6.3000e+0', '-6.3', 4);
T('-5.4e+2', '-542', 1);
T('-5.2000e+0', '-5.2', 4);
T('-9.00000e-2', '-0.09', 5);
T('-3.1000e-1', '-0.31', 4);
T('-4.4e+2', '-436', 1);
T('-3.00e+0', '-3', 2);
T('-5.00e-2', '-0.05', 2);
T('1.00e-2', '0.01', 2);
T('1.230e+2', '12.3e1',BigNumber('3'));
T('1.23e+2', '12.3e1', null);
T('1.23e+2', '12.3e1', undefined);
T('1e+2', '12.3e1', '0');
T('1e+2', '12.3e1', '-0');
T('1e+2', '12.3e1', '-0.000000');
T('1e+2', '12.3e1', 0);
T('1e+2', '12.3e1', -0);
assertException(function () {new BigNumber('1.23').toExponential(NaN)}, "('1.23').toExponential(NaN)");
assertException(function () {new BigNumber('1.23').toExponential('NaN')}, "('1.23').toExponential('NaN')");
assertException(function () {new BigNumber('1.23').toExponential([])}, "('1.23').toExponential([])");
assertException(function () {new BigNumber('1.23').toExponential({})}, "('1.23').toExponential({})");
assertException(function () {new BigNumber('1.23').toExponential('')}, "('1.23').toExponential('')");
assertException(function () {new BigNumber('1.23').toExponential(' ')}, "('1.23').toExponential(' ')");
assertException(function () {new BigNumber('1.23').toExponential('hello')}, "('1.23').toExponential('hello')");
assertException(function () {new BigNumber('1.23').toExponential('\t')}, "('1.23').toExponential('\t')");
assertException(function () {new BigNumber('1.23').toExponential(new Date)}, "('1.23').toExponential(new Date)");
assertException(function () {new BigNumber('1.23').toExponential(new RegExp)}, "('1.23').toExponential(new RegExp)");
assertException(function () {new BigNumber('1.23').toExponential(2.01)}, "('1.23').toExponential(2.01)");
assertException(function () {new BigNumber('1.23').toExponential(10.5)}, "('1.23').toExponential(10.5)");
assertException(function () {new BigNumber('1.23').toExponential('1.1e1')}, "('1.23').toExponential('1.1e1')");
assertException(function () {new BigNumber('1.23').toExponential(true)}, "('1.23').toExponential(true)");
assertException(function () {new BigNumber('1.23').toExponential(false)}, "('1.23').toExponential(false)");
assertException(function () {new BigNumber('1.23').toExponential(function (){})}, "('1.23').toExponential(function (){})");
assertException(function () {new BigNumber(12.3).toExponential('-1')}, ".toExponential('-1')");
assertException(function () {new BigNumber(12.3).toExponential(-23)}, ".toExponential(-23)");
assertException(function () {new BigNumber(12.3).toExponential(1e9 + 1)}, ".toExponential(1e9 + 1)");
assertException(function () {new BigNumber(12.3).toExponential(1e9 + 0.1)}, ".toExponential(1e9 + 0.1)");
assertException(function () {new BigNumber(12.3).toExponential(-0.01)}, ".toExponential(-0.01)");
assertException(function () {new BigNumber(12.3).toExponential('-1e-1')}, ".toExponential('-1e-1')");
assertException(function () {new BigNumber(12.3).toExponential(Infinity)}, ".toExponential(Infinity)");
assertException(function () {new BigNumber(12.3).toExponential('-Infinity')}, ".toExponential('-Infinity')");
BigNumber.config({ERRORS : false});
T('Infinity', Infinity, 0);
T('Infinity', Infinity, NaN);
T('Infinity', Infinity, null);
T('Infinity', Infinity, Infinity);
T('NaN', NaN, -Infinity);
T('1.230e+2', '12.3e1', BigNumber(3));
T('1.23e+2', '12.3e1', null);
T('1.23e+2', '12.3e1', undefined);
T('1.23e+2', '12.3e1', NaN);
T('1.23e+2', '12.3e1', 'NaN');
T('1.23e+2', '12.3e1', []);
T('1.23e+2', '12.3e1', {});
T('1.23e+2', '12.3e1', '');
T('1.23e+2', '12.3e1', ' ');
T('1.23e+2', '12.3e1', 'hello');
T('1.23e+2', '12.3e1', '\t');
T('1.23e+2', '12.3e1', ' ');
T('1.23e+2', '12.3e1', new Date);
T('1.23e+2', '12.3e1', new RegExp);
T('1e+2', '12.3e1', -0);
T('1.2e+2', '12.3e1', 1.999);
T('1.2300000e+2', '12.3e1', 7.5);
T('1.23000000000e+2', '12.3e1', '1.1e1');
T('1.23e+2', '12.3e1', '-1');
T('1.23e+2', '12.3e1', -23);
T('1.23e+2', '12.3e1', 1e9 + 1);
T('1.23e+2', '12.3e1', 1e9 + 0.1);
T('1.23e+2', '12.3e1', -0.01);
T('1.23e+2', '12.3e1', '-1e-1');
T('1.23e+2', '12.3e1', Infinity);
T('1.23e+2', '12.3e1', '-Infinity');
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : true,
RANGE : 1E9,
EXPONENTIAL_AT : 1E9
});
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

1499
test/toFixed.js Normal file

File diff suppressed because it is too large Load Diff

3037
test/toFraction.js Normal file

File diff suppressed because it is too large Load Diff

852
test/toPrecision.js Normal file
View File

@ -0,0 +1,852 @@
var count = (function toPrecision(BigNumber) {
var start = +new Date(),
log,
error,
undefined,
passed = 0,
total = 0;
if (typeof window === 'undefined') {
log = console.log;
error = console.error;
} else {
log = function (str) { document.body.innerHTML += str.replace('\n', '<br>') };
error = function (str) { document.body.innerHTML += '<div style="color: red">' +
str.replace('\n', '<br>') + '</div>' };
}
if (!BigNumber && typeof require === 'function') BigNumber = require('../bignumber');
function assert(expected, actual) {
total++;
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
//process.exit();
}
else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
function assertException(func, message) {
var actual;
total++;
try {
func();
} catch (e) {
actual = e;
}
if (actual && actual.name == 'BigNumber Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a BigNumber Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, precision){
assert(String(expected), new BigNumber(value).toPrecision(precision));
}
log('\n Testing toPrecision...');
BigNumber.config({
DECIMAL_PLACES : 20,
ROUNDING_MODE : 4,
ERRORS : true,
RANGE : 1E9,
EXPONENTIAL_AT : [-7, 40]
});
// ---------------------------------------------------------------- v8 start
T('1e+27', '1.2345e+27', 1);
T('1.2e+27', '1.2345e+27', 2);
T('1.23e+27', '1.2345e+27', 3);
T('1.235e+27', '1.2345e+27', 4);
T('1.2345e+27', '1.2345e+27', 5);
T('1.23450e+27', '1.2345e+27', 6);
T('1.234500e+27', '1.2345e+27', 7);
T('-1e+27', '-1.2345e+27', 1);
T('-1.2e+27', '-1.2345e+27', 2);
T('-1.23e+27', '-1.2345e+27', 3);
T('-1.235e+27', '-1.2345e+27', 4);
T('-1.2345e+27', '-1.2345e+27', 5);
T('-1.23450e+27', '-1.2345e+27', 6);
T('-1.234500e+27', '-1.2345e+27', 7);
T('7', 7, 1);
T('7.0', 7, 2);
T('7.00', 7, 3);
T('-7', -7, 1);
T('-7.0', -7, 2);
T('-7.00', -7, 3);
T('9e+1', 91, 1);
T('91', 91, 2);
T('91.0', 91, 3);
T('91.00', 91, 4);
T('-9e+1', -91, 1);
T('-91', -91, 2);
T('-91.0', -91, 3);
T('-91.00', -91, 4);
T('9e+1', 91.1234, 1);
T('91', 91.1234, 2);
T('91.1', 91.1234, 3);
T('91.12', 91.1234, 4);
T('91.123', 91.1234, 5);
T('91.1234', 91.1234, 6);
T('91.12340', 91.1234, 7);
T('91.123400', 91.1234, 8);
T('-9e+1', -91.1234, 1);
T('-91', -91.1234, 2);
T('-91.1', -91.1234, 3);
T('-91.12', -91.1234, 4);
T('-91.123', -91.1234, 5);
T('-91.1234', -91.1234, 6);
T('-91.12340', -91.1234, 7);
T('-91.123400', -91.1234, 8);
T('NaN', NaN, 1);
T('Infinity', Infinity, 2);
T('-Infinity', -Infinity, 2);
T('5.55000000000000e-7', 0.000000555, 15);
T('-5.55000000000000e-7', -0.000000555, 15);
T('-1.2e-9', -.0000000012345, 2);
T('-1.2e-8', -.000000012345, 2);
T('-1.2e-7', -.00000012345, 2);
T('1e+8', 123456789, 1);
T('123456789', 123456789, 9);
T('1.2345679e+8', 123456789, 8);
T('1.234568e+8', 123456789, 7);
T('-1.234568e+8', -123456789, 7);
T('-0.0000012', -.0000012345, 2);
T('-0.000012', -.000012345, 2);
T('-0.00012', -.00012345, 2);
T('-0.0012', -.0012345, 2);
T('-0.012', -.012345, 2);
T('-0.12', -.12345, 2);
T('-1.2', -1.2345, 2);
T('-12', -12.345, 2);
T('-1.2e+2', -123.45, 2);
T('-1.2e+3', -1234.5, 2);
T('-1.2e+4', -12345, 2);
T('-1.235e+4', -12345.67, 4);
T('-1.234e+4', -12344.67, 4);
T('1.3', 1.25, 2);
T('1.4', 1.35, 2);
T('1e+4', 9631.01, 1);
T('1.0e+7', 9950095.87, 2);
T('1e+1', '9.856839969', 1);
T('1e+2', '97.504', 1);
T('1e+5', 97802.6, 1);
T('1e+1', 9.9617, 1);
T('1e+3', 989.2, 1);
T('1.0e+5', 99576, 2);
T('1e+8', '96236483.87', 1);
// ------------------------------------------------------------------ v8 end
BigNumber.config({ROUNDING_MODE : 0});
T('-0.000090000000', '-0.00009', 8);
T('-7e-7', '-0.0000007', 1);
T('68.9316834061848', '68.931683406184761912218250317', 15);
T('7.8601018089704732e+27', '7860101808970473167417935916.60087069', 17);
T('3.21445885399803244067719798337437062000000e-11', '0.0000000000321445885399803244067719798337437062', 42);
T('-8171786349835057630612358814.162756978', '-8171786349835057630612358814.162756977984', 37);
T('3340.9039701', '3340.903970019817086594869184429527413533291595472085', 11);
T('-7269097658095414435895.9161181115739745427300313060', '-7269097658095414435895.916118111573974542730031306', 50);
T('0.00000632207', '0.00000632206077863', 6);
T('6e+2', '573', 1);
T('7.4e-7', '0.000000738', 2);
T('-5.031561e-7', '-0.0000005031560306227217140253964236911907612837', 7);
T('-4.291e+11', '-429050053964', 4);
T('8.514e+7', '85131637', 4);
T('-3.4e-9', '-0.000000003326783057540398442677461', 2);
T('6.9404295962722512e-20', '0.00000000000000000006940429596272251146200868514973032594273', 17);
T('-828376248340605120247.15155295014', '-828376248340605120247.15155295013990774586360178257303370779', 32);
T('-7.9828e+6', '-7982750.6677764682946015520272838914918899297118139169410659', 5);
T('0.00712610393722542527880200', '0.007126103937225425278801997738', 24);
T('-5.7e+4', '-56242', 2);
T('-8928855203945443164.755136735230293537', '-8928855203945443164.755136735230293536124112124', 37);
T('5218572327.99', '5218572327.98424443372003772604597054153304', 12);
T('71707870535238750871516796339.60', '71707870535238750871516796339.59678962573869890935', 31);
T('88817462.7137982220652429', '88817462.71379822206524285939115943006583441400005007918', 24);
T('3.00000e-9', '0.000000003', 6);
T('-6.053', '-6.05291095813493573191', 4);
T('6.51630828677e+19', '65163082867698740076', 12);
T('2483202135696501.60187899', '2483202135696501.60187898870193199949004966876115645', 24);
T('1.0766e-10', '0.000000000107650515680635692286894826641576642261', 5);
T('642724503819056076.659397077514269963295025', '642724503819056076.659397077514269963295024012414', 42);
T('-7.1192e+21', '-7119169102619893823635.32141854354', 5);
T('-6.717481255640638829101946114674e-8', '-0.000000067174812556406388291019461146732616998258', 31);
T('-12.41976452', '-12.4197645179995365323309894', 10);
T('-6.529258780126449116249954644017839921024112900e-16', '-0.00000000000000065292587801264491162499546440178399210241129', 46);
T('-441838.0', '-441838', 7);
T('1.128285293592950e-8', '0.000000011282852935929493101783925259749957192', 16);
T('-8.654857e+7', '-86548567', 7);
T('3.8883293855303995e-7', '0.00000038883293855303994672627854769926811949', 17);
T('3.25870000e-13', '0.00000000000032587', 9);
T('3.702e+6', '3701031.59037494113', 4);
T('-3580077435.93682917449675702508371047', '-3580077435.93682917449675702508371046631533', 36);
T('-7.400', '-7.4', 4);
T('109519523263844229810.068', '109519523263844229810.067657779734413280795410968892638', 24);
T('-509247322311590671954830.86847660619', '-509247322311590671954830.8684766061855', 35);
T('7.5518638430980800496570562671727890e-10', '0.00000000075518638430980800496570562671727889997', 35);
T('-5056721600639122835615986051.468831942818200', '-5056721600639122835615986051.4688319428182', 43);
T('-1.796146861125551785886171829251460000000000e-16', '-0.000000000000000179614686112555178588617182925146', 43);
T('6.0e+2', '599', 2);
T('7.619930e-16', '0.00000000000000076199293', 7);
T('834668.2370121038159610193', '834668.237012103815961019258574789273273342', 25);
T('-3.92251395952329649490768e+26', '-392251395952329649490767912.240768552138247705202732', 24);
T('-47504099413385554632166.5098', '-47504099413385554632166.50972492550706', 27);
T('-763912347.2814762', '-763912347.28147614121123622213255703', 16);
T('62.06092655083887409325613', '62.06092655083887409325612694639', 25);
T('-5262696454512614512.606481226453660', '-5262696454512614512.6064812264536594032183632269343356197', 34);
T('-324.4757687696223789483683661674', '-324.475768769622378948368366167382', 31);
T('41034172.92', '41034172.91600339960206', 10);
T('78.8705822927994376887853', '78.870582292799437688785229493004059423117558', 24);
T('13.2', '13.12562822628823049', 3);
T('-47510172284493547923917836.573231120531506713', '-47510172284493547923917836.573231120531506712946048319', 44);
T('-762632827', '-762632826.1', 9);
T('4e+13', '33953600811490.5124040357996528537249966', 1);
T('-8.1071720769966e+25', '-81071720769965824452477185.9774686', 14);
T('5.680e+22', '56797151043432713156004.54588148769825716', 4);
T('-32.861964853600294215914162138', '-32.8619648536002942159141621375696711453', 29);
T('-30816296472.656223819', '-30816296472.656223818627686674207740641739447', 20);
T('9.085158071966474886768332e+30', '9085158071966474886768331250478.08286703003069431737582', 25);
T('-504664.230671', '-504664.230670963', 12);
T('-1.013105775e+16', '-10131057742551895.1862632947', 10);
T('-542318552011993.7986', '-542318552011993.798599548369674038472319697531161473933214', 19);
T('-9.0310e+16', '-90309463572405956', 5);
T('-6.771931816', '-6.77193181559601521980141', 10);
T('4703514776786483.3', '4703514776786483.2838035091610781996968798', 17);
T('-8.43684044711e+12', '-8436840447101.126789480845', 12);
T('-343.5602326850284', '-343.56023268502830337554680474463898876525434', 16);
T('-3.17649252e+24', '-3176492517226717196752073', 9);
T('-2.3912888503759090e+28', '-23912888503759089673174904075', 17);
T('6.8853846820341808e+23', '688538468203418073592188', 17);
T('4e+17', '343455415908256944', 1);
T('-1.4e+9', '-1336106841', 2);
T('-2244450.2134814273335263', '-2244450.2134814273335262397290334104071203538487453309626146', 23);
T('8.74e+29', '873625255363763952428129881990.679929486040461455296118489', 3);
T('-1.85453549733179613185923288786', '-1.8545354973317961318592328878502252820666161607740183', 30);
T('431.7150651927', '431.71506519265522010949747887049', 13);
T('-8606297211156287.52520023752564', '-8606297211156287.5252002375256362382564355963505470716151', 30);
T('-8.4634889709e+24', '-8463488970828351722405003.220603', 11);
BigNumber.config({ROUNDING_MODE : 1});
T('-844789036.5239726', '-844789036.52397268892', 16);
T('-5056.20629012767878749185273209679064306054', '-5056.206290127678787491852732096790643060542', 42);
T('-0.3287519131314873763501859870298952500', '-0.32875191313148737635018598702989525', 37);
T('-60729764', '-60729764', 8);
T('-7.622e-14', '-0.00000000000007622481594531380999826456196664586', 4);
T('-4686402261639729535.736324492474', '-4686402261639729535.7363244924747488', 31);
T('-2.0', '-2', 2);
T('-13801188035233586637950193108.13592574381473451125649500', '-13801188035233586637950193108.135925743814734511256495', 55);
T('0.0000807327587149839799300000', '0.00008073275871498397993', 24);
T('-6.000000e-8', '-0.00000006', 7);
T('-3.83574993e+11', '-383574993535', 9);
T('7.6987000000000000e-14', '0.000000000000076987', 17);
T('80928866804.6112050947427973', '80928866804.6112050947427973864826014844575374353', 27);
T('-0.00730140', '-0.0073014067221009206110062377503733', 6);
T('2.72104773884160491036088486e+30', '2721047738841604910360884862459.4086993273252009015', 27);
T('3.008780781917733594e+25', '30087807819177335941398228.1424107931203', 19);
T('-1.31528920779613669158250146972297797867760000000000000000000e-19', '-0.00000000000000000013152892077961366915825014697229779786776', 60);
T('-8.5e+11', '-858982311008.257025719798657844609315293821', 2);
T('-3.6312e-12', '-0.0000000000036312827608449878', 5);
T('-0.0060000', '-0.006', 5);
T('-1e+1', '-12', 1);
T('5.779447e+14', '577944759667712', 7);
T('-8.753124714248104872487955947563035887800000000000e-13', '-0.00000000000087531247142481048724879559475630358878', 49);
T('0.000736948830704113912', '0.000736948830704113912970821957479', 18);
T('-4.65727e+23', '-465727983501322687372765', 6);
T('-0.00000332331666628036603', '-0.000003323316666280366035430077076052', 18);
T('3.533702e-8', '0.00000003533702791135712510338001418872124', 7);
T('-0.04340', '-0.0434', 4);
T('-597340.278566069086858587852236235470', '-597340.2785660690868585878522362354706741', 36);
T('6.000e-8', '0.00000006', 4);
T('-3.624323359112776296e-19', '-0.00000000000000000036243233591127762966338166', 19);
T('-3731378568692042924197.154', '-3731378568692042924197.15400334142251496795634388', 25);
T('-68249040894032065692.62', '-68249040894032065692.62771690318493', 22);
T('8786096722661914.89732851', '8786096722661914.89732851188880184891692993684242690315', 24);
T('-1.8413321536281347264486372900000000000e-12', '-0.00000000000184133215362813472644863729', 38);
T('4.0e-9', '0.0000000040395827543504045', 2);
T('-2.9427e+16', '-29427119846374896', 5);
T('-917760614.4', '-917760614.45404359204911454', 10);
T('8e+4', '89427', 1);
T('0.00000920323988134356953828667260', '0.0000092032398813435695382866726', 27);
T('8.2e+16', '82068995955708118', 2);
T('3.35195944828e+26', '335195944828445911672446409.3379497158141', 12);
T('-3.89774891030e-9', '-0.00000000389774891030223957363124620581272897758735065471', 12);
T('-4', '-4', 1);
T('8', '8', 1);
T('1.41172955693912934219137966000000e-10', '0.000000000141172955693912934219137966', 33);
T('9.21481e+13', '92148111958857', 6);
T('-5.859975978432853e-18', '-0.0000000000000000058599759784328539', 16);
T('-72.0', '-72', 3);
T('3785098751297.8929911950994079707157472', '3785098751297.89299119509940797071574729867819252140059', 38);
T('4.38e+16', '43893416753778361.297703358127215475077814', 3);
T('-33110.29096', '-33110.2909623520267070846514', 10);
T('-74.38305251784882707720486436292121914036495', '-74.3830525178488270772048643629212191403649548392158614', 43);
T('-4.31091381814e+27', '-4310913818147299779611829988.1707181186375975966133328', 12);
T('-1e+7', '-19238355', 1);
T('-6996635475270055814687.6', '-6996635475270055814687.6250552375470211825551', 23);
T('-8.203834974e+12', '-8203834974826.23347025', 10);
T('-7.4775e+5', '-747754.16564979702874976822', 5);
T('-9.291256959320e+23', '-929125695932058727753757.0232350927089256760451379', 13);
T('8.5e+11', '853985704471', 2);
T('-6.6560212', '-6.65602121044617863313449309597493831', 8);
T('1785977942777.20398797', '1785977942777.2039879764361236566223563439', 21);
T('6.1333504356e+23', '613335043569565749922342.8859983523919141148812213832', 11);
T('-5.6e+8', '-565718507', 2);
T('87732918932081', '87732918932081.5225691355449629111825', 14);
T('34510.55200915393645123', '34510.55200915393645123649', 22);
T('80406604570281847.64813851700344044652354', '80406604570281847.648138517003440446523542379', 40);
T('4350.66340515', '4350.66340515436550356256', 12);
T('-1.795651762606996e+19', '-17956517626069967584.285356976401607845756322546530214497', 16);
T('9.162e+24', '9162436195089050810891391.493612', 4);
T('-7.82552e+6', '-7825522.1080200627404337', 6);
T('-358162040.1796393759838430', '-358162040.17963937598384303781972517649539', 25);
T('-20732451778.4', '-20732451778.464877395794562570976729066571095229', 12);
T('-239748.58739', '-239748.5873964402372997371903319', 11);
T('-6.106537e+9', '-6106537070.58700935776016694', 7);
T('4e+23', '405561947729011104089456.7617832102516', 1);
T('-1.7252987e+10', '-17252987633.58674364430598655792', 8);
T('61.38960691398015334867512513960', '61.3896069139801533486751251396015198659145775291764', 31);
T('-70493899102410752290043364.4667507415385', '-70493899102410752290043364.466750741538512', 39);
T('-891.3505', '-891.35058685025619', 7);
T('1.5e+8', '153705028.906', 2);
T('5.80e+18', '5805164734299168659.6173113885173384955443', 3);
T('-1.719875889271327', '-1.719875889271327133154458155573493605566221534', 16);
T('113.672129563', '113.672129563441659725876055771857758675550104070419635029', 12);
T('-77950052814622081084397.9', '-77950052814622081084397.91853869253589242574', 24);
T('4.53106985e+27', '4531069852787151785292512309.2901993579425172826443679877', 9);
T('45285.246089613169416440797840714', '45285.2460896131694164407978407142422013937', 32);
T('307760226411464.7333268079863299', '307760226411464.73332680798632996332324381779707', 31);
BigNumber.config({ROUNDING_MODE : 2});
T('-0.0300', '-0.0300921721159558', 3);
T('65317841202.20949859371772273480125', '65317841202.2094985937177227348012464402154', 34);
T('-8.9231575495202e+29', '-892315754952021994731329589682.1894180393920044085713', 14);
T('-2.8075679202e-8', '-0.0000000280756792028583066', 11);
T('9.71456e+9', '9714558552', 6);
T('2.9514099281e-10', '0.00000000029514099281', 11);
T('-1.24459e+14', '-124459985101107', 6);
T('0.0000734657394154607815562372000000', '0.0000734657394154607815562372', 30);
T('1.78719530353972e+15', '1787195303539715', 15);
T('-2.8e+9', '-2861102528', 2);
T('-8.74480375581000e-9', '-0.00000000874480375581', 15);
T('-1792404726015427380.248150830448457643618022', '-1792404726015427380.248150830448457643618022', 43);
T('-678437320202616518.2220157912209286', '-678437320202616518.22201579122092864', 34);
T('-1.937304915215780220809799809655893674619672771e-8', '-0.000000019373049152157802208097998096558936746196727718', 46);
T('824172.15863347130174103087', '824172.15863347130174103086069960571', 26);
T('1.90040714061724000e-9', '0.00000000190040714061724', 18);
T('-1634488249956745498.58311', '-1634488249956745498.58311123049258868631623840423306', 24);
T('0.0000019600923098540334001755857361187871270117098000', '0.0000019600923098540334001755857361187871270117098', 47);
T('8.383e+4', '83829', 4);
T('2.843306120337864064e+23', '284330612033786406376718', 19);
T('1.86235e+15', '1862340943682995.08270612464203237562317928642459', 6);
T('-2.31e+13', '-23195312138083', 3);
T('5.450237e+21', '5450236028274773541895.65198933808968167192289601277', 7);
T('-0.008976419749408075453861117865459', '-0.00897641974940807545386111786545972434475187220274239581167', 31);
T('-761181660548661030.25', '-761181660548661030.25539542029', 20);
T('-1844205.93619958', '-1844205.936199580689273072905714475263817', 15);
T('4842.77906784902805070438222238898372327093', '4842.77906784902805070438222238898372327092242428134814721', 42);
T('-4.161198953445629503503971e+26', '-416119895344562950350397179', 25);
T('1.084e+4', '10836', 4);
T('8.71081704218174598654542083000e-8', '0.0000000871081704218174598654542083', 30);
T('7.9139683e+36', '7913968291641940848703040206324645237.8515176490912667096', 8);
T('-0.000008', '-0.000008', 1);
T('8.3660085625e+34', '83660085624983922907621996804192921.3992927', 11);
T('0.000006980263008', '0.000006980263007423150706324065130475391', 10);
T('-31348084528321454060964445534333629317.69561497283830023', '-31348084528321454060964445534333629317.69561497283830023', 55);
T('-2417953792643886.3485495754363678888681996409674308643', '-2417953792643886.3485495754363678888681996409674308643', 53);
T('4.0e+6', '3982592', 2);
T('-2092315.015029722200', '-2092315.0150297222', 19);
T('-364992136844916.9092238', '-364992136844916.909223894931280218350055327754935', 22);
T('8.34e+24', '8333642861002789136219873', 3);
T('7.6008837179413e+14', '760088371794122.3380234188299740029832128019574765416', 14);
T('-6655726127.0', '-6655726127', 11);
T('-8.2157109e-9', '-0.000000008215710991605913786700324', 8);
T('-0.00007003302912717900', '-0.000070033029127179', 16);
T('-919151201.84874', '-919151201.8487431', 14);
T('-7.7284e+34', '-77284694095619151624570282373349775.20332', 5);
T('-0.01348565', '-0.013485650787487', 7);
T('4793.07921563762902275733457926767780', '4793.0792156376290227573345792676778', 36);
T('-29428.0', '-29428', 6);
T('-5.031066774187e+17', '-503106677418717710.020194320886816967824316089135', 13);
T('8.5822119333e+30', '8582211933222895201417193603829.362', 11);
T('3.69818e+29', '369817665788648417491163239098.45906115246177782675574', 6);
T('-16637318966.7921513256', '-16637318966.79215132564236', 21);
T('-3.511414e+7', '-35114143.07750577', 7);
T('-4.00583795e+15', '-4005837953660576.377392671047611906101', 9);
T('2.857013789e+29', '285701378835628725742568343419.93', 10);
T('3.784446708460892550157924e+30', '3784446708460892550157923126965.213', 25);
T('-8.07e+11', '-807835898139.8273423102575232570378422434793962915', 3);
T('7.2e+12', '7166828666682', 2);
T('-2.7e+15', '-2759498523697862.0885969105603319015115245', 2);
T('3.93e+3', '3920.77076847274147345709652305252825254482870430341848100141', 3);
T('-6e+12', '-6791423282682', 1);
T('-8.6204e+14', '-862048518070094.31', 5);
T('124280692175695486153.808', '124280692175695486153.80744660510519294193', 24);
T('-460557721667773.3587267520', '-460557721667773.3587267520989', 25);
T('-6268536499825359064300.23', '-6268536499825359064300.2317858', 24);
T('292408901.64362273508249026852286', '292408901.64362273508249026852285294673307', 32);
T('-649622345434955387029125.11357971191', '-649622345434955387029125.113579711917604812061404975326264229', 35);
T('-4.287461556179478781e+27', '-4287461556179478781817700851.131100167', 19);
T('-5.891552271022619e+29', '-589155227102261925251047170629.30784624401', 16);
T('1.88e+5', '187009.128', 3);
T('4299388.1132142278863818606739416640', '4299388.1132142278863818606739416639837103457725931818979', 35);
T('-7.8e+8', '-788088836.225886207482064192607002511282756502400977', 2);
T('-56025768755085222.404269', '-56025768755085222.404269295514', 23);
T('-8376.71149693765842', '-8376.71149693765842060199698996606139145426', 18);
T('-1.7218673528e+29', '-172186735288586033321621121024.11240623', 11);
T('-3.31e+28', '-33197729862068219255677464974', 3);
T('-4.835191326e+29', '-483519132605694848658321267839.23575134378118945659616358', 10);
T('7.3', '7.24882150443803', 2);
T('-89186640077683569.407061427673', '-89186640077683569.4070614276736450982125609', 29);
T('-49379651041268.5', '-49379651041268.548293', 15);
T('-7685054.17489171951660', '-7685054.17489171951660508194254495141726065698575306365447451', 21);
BigNumber.config({ROUNDING_MODE : 3});
T('-39449414270333.925852213835', '-39449414270333.925852213834759031494508489474', 26);
T('-7.50437989976', '-7.50437989975503711836768', 12);
T('-0.000004303975760000000', '-0.00000430397576', 16);
T('-16040233916257241895.97650633973989', '-16040233916257241895.9765063397398857', 34);
T('-7438.9287248601393819', '-7438.9287248601393818639176907606', 20);
T('9.857465584298e-7', '0.000000985746558429876825600458537705318327799', 13);
T('532637.9095983547284850466577958315920', '532637.90959835472848504665779583159203905641996', 37);
T('-1.40416695292e+30', '-1404166952915258058306475434520.7856110230505157', 12);
T('60346876.6670832429026869255506808488', '60346876.6670832429026869255506808488', 36);
T('-2.52466133e+23', '-252466132238128405832984', 9);
T('55', '55', 2);
T('8', '8', 1);
T('-63075151.962465776516325792253177939493172', '-63075151.9624657765163257922531779394931714', 41);
T('7.411461e+17', '741146113404361548.543142388', 7);
T('-58835755359067474972692072494278983.7', '-58835755359067474972692072494278983.6314961114191480012916', 36);
T('-3.5408424427810e+21', '-3540842442780946836975', 14);
T('-8.6985e+22', '-86984550895486812167623.3816747460029582321093085895', 5);
T('-4.4625326e+20', '-446253250722400223428', 8);
T('-79301328.93777304419247399162092400', '-79301328.937773044192473991620924', 34);
T('-1.6065669647394805e+28', '-16065669647394804383207152895.0285044537455', 17);
T('-333', '-333', 3);
T('7', '7', 1);
T('7.24707e+13', '72470760481059', 6);
T('39232618.1513515442233995765535454389', '39232618.151351544223399576553545438981252', 36);
T('-4e+5', '-357994', 1);
T('-1.90e+4', '-18904.11335233460016293296574557643545512393801643609213933', 3);
T('-6585152111956929.924309477123328984876184272828762900', '-6585152111956929.9243094771233289848761842728287629', 52);
T('4.505e-7', '0.0000004505328', 4);
T('-2.4125965461846e+19', '-24125965461845662271', 14);
T('4.82673137e+33', '4826731373891127996812671510065700.871947701', 9);
T('-6621278.2', '-6621278.1120573461544975284970826524341806671316100080257485', 8);
T('-1.8015392869565386634525164264799463344376205007391000000e-7', '-0.00000018015392869565386634525164264799463344376205007391', 56);
T('-0.00026465463574439280006655492609887593', '-0.00026465463574439280006655492609887592672292239588307259', 35);
T('4.87815228988300090', '4.8781522898830009076096556452567', 18);
T('-5.1107117199524082779077801201617e+35', '-511071171995240827790778012016163902', 32);
T('1.4734242515706890557e+20', '147342425157068905574.390834406', 20);
T('-4019325091848890817268596991.815200', '-4019325091848890817268596991.8152', 34);
T('3.8e+14', '384715413967421', 2);
T('7483444.49', '7483444.498791364040133403947480439118040376737700653', 9);
T('-594538312.6255', '-594538312.625485172379', 13);
T('0.00753000', '0.00753', 6);
T('8.1440148247e+13', '81440148247675.27449603492606125135884', 11);
T('8.444003009300e+21', '8444003009300239495556', 13);
T('2308.1529840912558574923966042774800185916972327325289', '2308.1529840912558574923966042774800185916972327325289261', 53);
T('2.67e+3', '2674.698673623', 3);
T('-2.82819136180287470854625537e+30', '-2828191361802874708546255368471.80800005766', 27);
T('518250411', '518250411', 9);
T('3.2e+4', '32661.9135347256259375001777960775509', 2);
T('29.15347602216416991973', '29.153476022164169919735054013077734177', 22);
T('-4.611285536613066108e+30', '-4611285536613066107912600830385', 19);
T('-51774110.0705144989023975360207167071143094356321', '-51774110.070514498902397536020716707114309435632036586', 48);
T('-11969053.91', '-11969053.9052', 10);
T('3102686944.558209725206279080384565972890930884678', '3102686944.5582097252062790803845659728909308846780130141', 49);
T('-3601967476456.11863985450841401751857855', '-3601967476456.1186398545084140175185785472952682624279698', 39);
T('-5e+15', '-4873768150955988', 1);
T('-352.0819', '-352.08189544801640267067628', 7);
T('-2.58805959847e+29', '-258805959846025073839294200101', 12);
T('-66245829859.35391480', '-66245829859.353914791938511206971693', 19);
T('1.54e+9', '1544806884.11336335261587391', 3);
T('-27.7997003414813453645099801', '-27.79970034148134536450998001339677019', 27);
T('14062458038542559389162.9204850167', '14062458038542559389162.9204850167680814', 33);
T('1.558308e+23', '155830857739562225455438.36', 7);
T('-191388637226531701343.3', '-191388637226531701343.25549694555307', 22);
T('5551.7364563066033013381', '5551.73645630660330133811512206', 23);
T('-374.187067', '-374.187066872511899560500516595762548924654039141', 9);
T('5608.7939', '5608.79395345957', 8);
T('-7.46461560634688e+16', '-74646156063468781.44597747432564', 15);
T('6.282e+14', '628222207265224.793350069927452126508488621324740335935808339', 4);
T('739267731.33076658725535583758', '739267731.3307665872553558375867276395038136046', 29);
T('-7.243744595180e+19', '-72437445951792218018.4147098155', 13);
T('148197.230592476071658991268667398', '148197.23059247607165899126866739893696346154456779371449089', 33);
T('-7326871.99257009310974109937661882759811033', '-7326871.9925700931097410993766188275981103204155306', 42);
T('-5.2007521e+21', '-5200752087996702875406.6925', 8);
T('9.00107829e+18', '9001078299504900356', 9);
T('229140061917', '229140061917.91723092039513459551808768805307572856707938', 12);
T('-6868103.8726464561656824818722569258791476905', '-6868103.872646456165682481872256925879147690458928033592856', 44);
T('-220947971933643883580237.50', '-220947971933643883580237.49534341528328', 26);
T('544164102001101766247312.91529628700', '544164102001101766247312.915296287008639054933', 35);
T('1.70e+23', '170271631736408409477543.35894', 3);
T('-5735975666.6511674981929172446', '-5735975666.65116749819291724455000274115296', 29);
T('-67513065.4797', '-67513065.4796695356', 12);
T('-9e+19', '-82164590986048729101.278942224271247884118371796531523', 1);
T('687378946204028.408158998985701', '687378946204028.408158998985701430935094', 30);
T('42.452', '42.4523909443358871476552683504968536100051', 5);
T('-22771061110217019663705702.44170142085172', '-22771061110217019663705702.44170142085171219649140996', 40);
T('-1470.640309974016167512235698629586', '-1470.6403099740161675122356986295857257144815364', 34);
T('-1.110228e+27', '-1110227398804733429555663947.06619', 7);
T('-6.4898237111e+26', '-648982371105405071851661301', 11);
T('-4641197449469148.658850361201903', '-4641197449469148.658850361201902222', 31);
BigNumber.config({ROUNDING_MODE : 4});
T('7.905300379788e+16', '79053003797878062.6454954', 13);
T('-6.83490000000e-13', '-0.00000000000068349', 12);
T('-62760641815.69084973661201201', '-62760641815.690849736612012010742308663', 28);
T('0.000704', '0.000704496313', 3);
T('82926865286287.8852357368342860830310721063079299643', '82926865286287.88523573683428608303107210630792996432', 51);
T('-0.00032388272393900301214220090249', '-0.00032388272393900301214220090248744799603424908', 29);
T('8.6e+12', '8621641486938.4837308885005093571508566552428700982454', 2);
T('2', '2', 1);
T('1.4641440117052559075e+20', '146414401170525590746.047955203899370771105088', 20);
T('3511.925583', '3511.925583', 10);
T('2861824.253079699095728', '2861824.253079699095727765750377038689', 22);
T('-3.940097756e+10', '-39400977564.548924098664431671700066962', 10);
T('-888', '-888', 3);
T('-0.000302106125213724988141721256104', '-0.00030210612521372498814172125610432438685', 30);
T('6943.4804552555315615809650428503', '6943.480455255531561580965042850266831249032130818358478956', 32);
T('3365678', '3365678.3397481381125085749', 7);
T('-5.3943374314e+19', '-53943374313769567458.386865325', 11);
T('-6.67880509225510150542252852147049489938254298497979', '-6.6788050922551015054225285214704948993825429849797925563674', 51);
T('1.36424e+18', '1364240644139816224.60228356028', 6);
T('1.410236477950416725e+23', '141023647795041672538410.84935693266374259666015274447', 19);
T('-802.817765', '-802.81776500697712984253334522', 9);
T('-5.276210722424690668896260075355037218851', '-5.27621072242469066889626007535503721885096', 40);
T('-0.000874209568970788', '-0.0008742095689707877849902027926289294748756775668387', 15);
T('0.092053833162002', '0.09205383316200189249855864903410820435666385119723209239', 14);
T('7.0656298318128209e-14', '0.0000000000000706562983181282092835675843980510112', 17);
T('-8.66511516852116659e+18', '-8665115168521166587', 18);
T('3.3490648464e+22', '33490648463534229842937.79268276945692333064632966129475', 11);
T('-39041587174692569176.82740706154183894', '-39041587174692569176.827407061541838942655371389185', 37);
T('-3834.0', '-3834', 5);
T('-0.008912382644814418776268630', '-0.00891238264481441877626863', 25);
T('-2.1e+5', '-206119', 2);
T('4.83340000000e-8', '0.000000048334', 12);
T('3.185196533675230520000000000000e-19', '0.000000000000000000318519653367523052', 31);
T('6.0431217298488095562718496137220939447806000000000000000e-17', '0.000000000000000060431217298488095562718496137220939447806', 56);
T('196.519569070149034', '196.51956907014903416531531', 18);
T('0.0000046405006597117307566000', '0.0000046405006597117307566', 23);
T('9.10e+16', '90974867783311624.1073050261392195984211985571898902', 3);
T('0.0009', '0.0009', 1);
T('-784.344', '-784.3442317667756502522526185951859933319162', 6);
T('4.407336482399797058693e+28', '44073364823997970586929155979.43263841350505', 22);
T('-3.0000000000e-13', '-0.0000000000003', 11);
T('0.800', '0.8', 3);
T('0.04643398170143261158595951942031', '0.046433981701432611585959519420314960367263', 31);
T('-8e+26', '-786589693451258754942279859.3834', 1);
T('-26.0', '-26', 3);
T('-8.462226728e+11', '-846222672789.2087639320702375427266333530942524245', 10);
T('-4e-7', '-0.0000004019666978288041783154210868', 1);
T('-315609.775843992', '-315609.775843992', 15);
T('-3.319e+9', '-3318880945', 4);
T('-6', '-6.2847', 1);
T('7.754663772705e+20', '775466377270546647581.033426922028458904663', 13);
T('-72577466365074249372160551.716563', '-72577466365074249372160551.71656300408', 32);
T('-7.8e+14', '-775743793612078', 2);
T('132441.1194131940273344', '132441.119413194027334448511114274180643744', 22);
T('-2e+8', '-175718250.88225246544054572629398592939731158738360059', 1);
T('8603217351572193.39188696', '8603217351572193.391886964766947146712574336', 24);
T('-9.1544942231978215224e+22', '-91544942231978215224182.9277714', 20);
T('2.67483212861962e+22', '26748321286196185405759.132664', 15);
T('-5812371.3', '-5812371.311809024582418495005304074', 8);
T('-4.56681272e+10', '-45668127184.1622', 9);
T('-6.833879652430027734e+28', '-68338796524300277341620461049.174596381', 19);
T('3.5253e+11', '352531868532', 5);
T('6.18754e+9', '6187538472.1814915517411034136013806202710623466754380762318', 6);
T('-49119914201836431396827151123.9982195', '-49119914201836431396827151123.99821949990542', 36);
T('-2.50e+18', '-2498994955335714645.22910610209', 3);
T('112714.50647532453078481574527706184222476885', '112714.50647532453078481574527706184222476884905812', 44);
T('1.3e+10', '13358297773', 2);
T('3.85346866600e+27', '3853468666000315958109987025.078941', 12);
T('-6.849e+16', '-68490080550892289', 4);
T('9.095', '9.094726073939375', 4);
T('4.6722099483e+12', '4672209948311.8638324115985415208264055834', 11);
T('-75494281.3585391383', '-75494281.3585391382541907932608754414663476859104837422712', 18);
T('7.9e+2', '787.7709059965548561711769118765', 2);
T('6103081090513.979878497219802', '6103081090513.9798784972198017843', 28);
T('-6207456599626114.392919', '-6207456599626114.39291886624528055513014220851925', 22);
T('844941600554602638837.461606663208684075561936', '844941600554602638837.461606663208684075561935576396', 45);
T('159438905444627555.28986', '159438905444627555.28985729196359392', 23);
T('-3688253681705278.414841830526919796661181971979', '-3688253681705278.4148418305269197966611819719792068915', 46);
T('-63', '-63.164640732796214571844119', 2);
T('2.8e+11', '276059026705.36069', 2);
T('357378.987253867425946425403370727230144', '357378.9872538674259464254033707272301441754336', 39);
T('1597.52674152596523825479', '1597.526741525965238254790848976407269408999607', 24);
T('4.63310587686706257280646279e+30', '4633105876867062572806462788592.801009', 27);
T('-6.21108762339449e+20', '-621108762339448671355.1393522133', 15);
T('8380435.063269894549337249', '8380435.063269894549337248813357930541546715547', 25);
BigNumber.config({ROUNDING_MODE : 5});
T('-1408003897645960.648499616456', '-1408003897645960.648499616456', 28);
T('-7719307749101742537.6299396338672184', '-7719307749101742537.6299396338672184334306', 35);
T('-1.0', '-1', 2);
T('-8.28e+14', '-827860423543649', 3);
T('0.00054398953021585321711560388890', '0.00054398953021585321711560388889590290139888', 29);
T('-4.409e-9', '-0.000000004408792', 4);
T('4.0000e-10', '0.0000000004', 5);
T('3.40e+16', '34001779327925905', 3);
T('-9.03e+34', '-90332622851356543193546536340366547', 3);
T('-4.5320e+16', '-45320100856429143.39155209710530673318222777', 5);
T('3.618e+30', '3618328715720583671291544414202', 4);
T('-1003.61140', '-1003.61139687804673322250551', 9);
T('-8139415035028632370.38737', '-8139415035028632370.38736602659835', 24);
T('8e+7', '83198058', 1);
T('-7.99492e+14', '-799491603856548', 6);
T('-3.351956508998634059456001730355207230e-9', '-0.000000003351956508998634059456001730355207229966', 37);
T('-14.69863659940007820467946969441090', '-14.698636599400078204679469694410899305', 34);
T('-8.1805185086529e+32', '-818051850865289066860294784032304.6373757407', 14);
T('8.21371840206651626757e+29', '821371840206651626756943367010.81915938727', 21);
T('444', '444', 3);
T('0.00000613258266938', '0.0000061325826693823067791292255878336353793864046451956723', 12);
T('-554696279951718746537611.26040', '-554696279951718746537611.26040029508470430208572833137315', 29);
T('446', '446.189185820662709163412845035853873', 3);
T('22873128187827109553471831451.06623850867', '22873128187827109553471831451.06623850866672688842662473', 40);
T('9e+5', '880389', 1);
T('-6.7516118890844e+16', '-67516118890844443.625641', 14);
T('-0.36107158435820', '-0.36107158435820101656696353075596201902674001080619510849', 14);
T('8.958386374640407365', '8.958386374640407364828679985365339921820421370157246', 19);
T('3e+2', '257', 1);
T('-1.904659739878e+18', '-1904659739878060478.113131137688927604413210083841', 13);
T('-0.0000627142', '-0.00006271421732891589577305487292334', 6);
T('3.310541e+8', '331054103', 7);
T('-1.793886e+23', '-179388600781592577147651.2641684828762234473', 7);
T('0.0004600', '0.00046', 4);
T('-2.9e+21', '-2906505321975413509885', 2);
T('86415.94739506', '86415.9473950557683374', 13);
T('6.730414', '6.7304135909152', 7);
T('-5.032367e+14', '-503236749968584', 7);
T('-5.0241682013868216287718e+32', '-502416820138682162877178622610283', 23);
T('-0.0552606118984074172116684879479087', '-0.0552606118984074172116684879479087', 33);
T('91017414629852252476380368766.471', '91017414629852252476380368766.47117955844005', 32);
T('28586.32124747000', '28586.32124747000107561236523943', 16);
T('0.000001935665545322534195131', '0.0000019356655453225341951305040536808235510260170838860718', 22);
T('7.8', '7.803563246406851025', 2);
T('-4.89914223627882382434323e+26', '-489914223627882382434323457.50920109688497974624541155867073', 24);
T('384718796891211107', '384718796891211107', 18);
T('42510.74002309897971230194', '42510.7400230989797123019438399853496258', 25);
T('-7.388e+11', '-738804895894', 4);
T('-5.0000000e-7', '-0.0000005', 8);
T('8.364583286198657757274487081e+29', '836458328619865775727448708084.5405786', 28);
T('-6.24e+26', '-624168076184333836471774105.20710913228879473008695839055', 3);
T('19804.9', '19804.875536771730958444190952514101502', 6);
T('-74106.212623408289', '-74106.2126234082888281', 17);
T('7432670190286.34100080472041', '7432670190286.341000804720411465540223412277267472', 27);
T('5.3250588635e+21', '5325058863479337983860.6152606488098384817869174221885211', 11);
T('6.865e+9', '6865129903.657345356274690732979469003170132760589', 4);
T('5795370.885430786885', '5795370.8854307868847728814464165810658237393757773', 19);
T('-29172007010418365641.7578738', '-29172007010418365641.7578738219989133084908106406123747833195', 27);
T('-62322.86188017646654', '-62322.8618801764665355127105700053481622040465444574371', 19);
T('-6374', '-6373.604850300043463878', 4);
T('5.846101e+26', '584610089745513547435367965.045755404292155403517947658', 7);
T('-4.9589e+12', '-4958880864611.79783789828786433416628187354312472853462765', 5);
T('-976.708', '-976.7080061576', 6);
T('-6.265387e+7', '-62653867.768253566156', 7);
T('5.943e+14', '594338013726832.675613519', 4);
T('5.0e+27', '5018407166428602036582808244', 2);
T('9e+16', '86282182181939888.936', 1);
T('-5319867042361146027.570343834017247178243381990233', '-5319867042361146027.5703438340172471782433819902325543283', 49);
T('-280.611828072', '-280.611828072476084775', 12);
T('497125.5349688434079217115738652', '497125.5349688434079217115738651759109278602', 31);
T('-8.74679213554e+15', '-8746792135535203.818773729011249091171163901426235584485964', 12);
T('2750816434321727711.90126468620', '2750816434321727711.901264686199491277747822638', 30);
T('-804111355.871490666462196181', '-804111355.8714906664621961811894645876', 27);
T('5592072638309750852858746183.6506680977', '5592072638309750852858746183.6506680977126', 38);
T('-4.0e+20', '-400904317147714566361', 2);
T('-3.9e+26', '-390267222260748697649150634.14444', 2);
T('43.2', '43.2482', 3);
T('42334337596496149636254', '42334337596496149636254.4926162509306406461', 23);
T('-7e+9', '-7246374971.34279698356', 1);
T('71516263932998764871838469072', '71516263932998764871838469072.280115355524', 29);
T('71257489.5995227415169007618702182092', '71257489.59952274151690076187021820922744', 36);
T('268492835', '268492834.77041', 9);
T('50325.551277778107847798802', '50325.551277778107847798801525', 26);
T('-5.289303987e+29', '-528930398665449048343281311623.69686', 10);
BigNumber.config({ROUNDING_MODE : 6});
T('0.08000', '0.08', 4);
T('-4.5132e+21', '-4513243388120382069815.8508153058993058875', 5);
T('-73549', '-73549.2594630551663822238', 5);
T('1.275868004728922895890883e+29', '127586800472892289589088296800.6', 25);
T('-0.0003715444034899460421534099962225699000', '-0.0003715444034899460421534099962225699', 37);
T('-6.9625565265e+24', '-6962556526511822306135536', 11);
T('1.67583703641e+13', '16758370364138.915293525076269061228714877', 12);
T('-173594.95064085553515176707313947534918109631092170', '-173594.950640855535151767073139475349181096310921699', 50);
T('-6.9503965525e+19', '-69503965525000308384.151383', 11);
T('4.411225e+20', '441122486054080817112', 7);
T('2.467044064783596937642371770e+31', '24670440647835969376423717700462.39', 28);
T('3.9711897549481645654e+24', '3971189754948164565361634.8039734590476326224193520402091769', 20);
T('-1.4757613208690e+21', '-1475761320868963235919.64499841336073105746686372924161', 14);
T('91683083887068.6191146', '91683083887068.61911461351134520171343337804061135', 21);
T('-7923074181102822.578', '-7923074181102822.5778', 19);
T('-6.800e-8', '-0.000000068', 4);
T('-2.57954671081460000000e-10', '-0.00000000025795467108146', 21);
T('5.5352911972e-9', '0.000000005535291197169667611325365189624523452', 11);
T('6.0488358e+8', '604883577', 8);
T('3', '3', 1);
T('-4.072637936805672015603149446630136089530560102165', '-4.0726379368056720156031494466301360895305601021653459970194', 49);
T('-7.2e+10', '-71689970391', 2);
T('655754242958.1563938760094919', '655754242958.15639387600949190369', 28);
T('-7.575535014e-9', '-0.00000000757553501363609536678641245355', 10);
T('7.547067960578900230644488e-10', '0.00000000075470679605789002306444877998602723', 25);
T('-3.64561456763e+12', '-3645614567625.4', 12);
T('9.0e-7', '0.0000009', 2);
T('7e+2', '687', 1);
T('517277827334839.8174848543680868', '517277827334839.8174848543680868015165926618', 31);
T('7e+2', '655.46270361324473194', 1);
T('1632131488313153.49737424823493573157', '1632131488313153.497374248234935731568', 36);
T('274068317992.5998880719845028748169734442', '274068317992.5998880719845028748169734442394151076', 40);
T('-7.060e-9', '-0.00000000706025531009734073', 4);
T('0.004444', '0.0044439457493', 4);
T('72482770689153111154104782082.023', '72482770689153111154104782082.022764082943227214833851', 32);
T('5.9130694036072794206e+24', '5913069403607279420613864.152', 20);
T('843384561300245347961437.966', '843384561300245347961437.96592523791', 27);
T('0.0000035198821282510000000', '0.000003519882128251', 20);
T('-1.00371560130267706870097e-9', '-0.00000000100371560130267706870096885251', 24);
T('17504218.4970302', '17504218.49703016415913667026121376499', 15);
T('-5e-9', '-0.000000005169058703', 1);
T('6.922803246e+10', '69228032455', 10);
T('-16', '-16', 2);
T('-1.355147513468192707127939151e+40', '-13551475134681927071279391508441439066206.58705380600075', 28);
T('81670324.1197758695', '81670324.1197758695212865075629796973196504241126', 18);
T('0.00005', '0.00004797485174640366805332660647', 1);
T('-4.864397594e-10', '-0.0000000004864397594461335282648538530108953965681345', 10);
T('47694105.2312532', '47694105.23125322528167211284521303', 15);
T('-4.962106181e+26', '-496210618135432953927871636.779236', 10);
T('1.2800030559497062236642e+37', '12800030559497062236641930592334626609.7332', 23);
T('-574830783.7', '-574830783.6689168903917696583746514637433390929', 10);
T('5969.431086199057470', '5969.43108619905746956015212970904111744101', 19);
T('-4.8e+3', '-4814.32904953003285', 2);
T('4.297e+16', '42973001760252134', 4);
T('-5.7628e+6', '-5762846.590152347665179652381407653797146356303622218259885', 5);
T('904864662232032.160612401810317927291657403142932', '904864662232032.16061240181031792729165740314293194205879163', 48);
T('7.9892e+20', '798923115068265241915.537619430376605', 5);
T('-8.97759349384000643', '-8.97759349384000643427096282979', 18);
T('841598023200278219780', '841598023200278219780.04764720909930685', 21);
T('7.294115e+17', '729411462980818078', 7);
T('-493854.469231', '-493854.46923056217873', 12);
T('1.16760483177812e+16', '11676048317781198.761924013', 15);
T('4.91431629960536e+17', '491431629960536053.49611060493021241774', 15);
T('-391357204564683265466220678.5248961969115394056441165', '-391357204564683265466220678.524896196911539405644116478', 52);
T('-1138622.4269179222525707405725062065185867', '-1138622.42691792225257074057250620651858665807616', 41);
T('7762491414507273289587174.60526', '7762491414507273289587174.60526424654003', 30);
T('-8.34305e+12', '-8343051798787.85784573983', 6);
T('-448090139696.5', '-448090139696.540044682', 13);
T('-249554483941810.04760758280384259798256931579', '-249554483941810.0476075828038425979825693157901967215767', 44);
T('-4937249656843391.056849', '-4937249656843391.056849458', 22);
T('-4.90029240789e+24', '-4900292407887576632220011.4', 12);
T('884134', '884134.30546381722', 6);
T('-67686.285431006', '-67686.2854310057290328136776917246126204655', 14);
T('5.1454907927786956678e+21', '5145490792778695667848.5080878826658832100351133', 20);
T('-3.75540093e+9', '-3755400930.115945946791361377756114557824815082', 9);
T('790548.1', '790548.055405', 7);
T('21.9776441681934305611827', '21.9776441681934305611826542081066055', 24);
T('-8.62915591e+12', '-8629155908036.5010483', 9);
T('-62521191175', '-62521191175.03721539877599449', 11);
T('-63947010170235145618893.55048', '-63947010170235145618893.55048264587643', 28);
T('-4.4791e+5', '-447912.9929543492037', 5);
T('876897.06887720787797443065', '876897.0688772078779744306464727', 26);
T('-609834676.749497163216150672711104329822616519', '-609834676.749497163216150672711104329822616518762', 45);
T('-2.9407315435e+18', '-2940731543474095094.56340709357589521', 11);
T('243028.94040290384317164750687246', '243028.940402903843171647506872458168411478', 32);
T('5313610990.737', '5313610990.7373810218', 13);
T('-3.56e+4', '-35566.4678487', 3);
T('123', '12.345e1', BigNumber(3));
T('123.45', '12.345e1', null);
T('123.45', '12.345e1', undefined);
assertException(function () {new BigNumber(1.23).toPrecision(NaN)}, "(1.23).toPrecision(NaN)");
assertException(function () {new BigNumber(1.23).toPrecision('NaN')}, "(1.23).toPrecision('NaN')");
assertException(function () {new BigNumber(1.23).toPrecision([])}, "(1.23).toPrecision([])");
assertException(function () {new BigNumber(1.23).toPrecision({})}, "(1.23).toPrecision({})");
assertException(function () {new BigNumber(1.23).toPrecision('')}, "(1.23).toPrecision('')");
assertException(function () {new BigNumber(1.23).toPrecision(' ')}, "(1.23).toPrecision(' ')");
assertException(function () {new BigNumber(1.23).toPrecision('hello')}, "(1.23).toPrecision('hello')");
assertException(function () {new BigNumber(1.23).toPrecision('\t')}, "(1.23).toPrecision('\t')");
assertException(function () {new BigNumber(1.23).toPrecision(new Date)}, "(1.23).toPrecision(new Date)");
assertException(function () {new BigNumber(1.23).toPrecision(new RegExp)}, "(1.23).toPrecision(new RegExp)");
assertException(function () {new BigNumber(1.23).toPrecision(2.01)}, "(1.23).toPrecision(2.01)");
assertException(function () {new BigNumber(1.23).toPrecision(10.5)}, "(1.23).toPrecision(10.5)");
assertException(function () {new BigNumber(1.23).toPrecision('1.1e1')}, "(1.23).toPrecision('1.1e1')");
assertException(function () {new BigNumber(1.23).toPrecision(true)}, "(1.23).toPrecision(true)");
assertException(function () {new BigNumber(1.23).toPrecision(false)}, "(1.23).toPrecision(false)");
assertException(function () {new BigNumber(1.23).toPrecision(function (){})}, "(1.23).toPrecision(function (){})");
assertException(function () {new BigNumber('12.345e1').toPrecision('-1')}, ".toPrecision('-1')");
assertException(function () {new BigNumber('12.345e1').toPrecision(-23)}, ".toPrecision(-23)");
assertException(function () {new BigNumber('12.345e1').toPrecision(1e9 + 1)}, ".toPrecision(1e9 + 1)");
assertException(function () {new BigNumber('12.345e1').toPrecision(1e9 + 0.1)}, ".toPrecision(1e9 + 0.1)");
assertException(function () {new BigNumber('12.345e1').toPrecision(0)}, ".toPrecision(0)");
assertException(function () {new BigNumber('12.345e1').toPrecision('-0')}, ".toPrecision('-0')");
assertException(function () {new BigNumber('12.345e1').toPrecision(0.9)}, ".toPrecision(0.9)");
assertException(function () {new BigNumber('12.345e1').toPrecision('-1e-1')}, ".toPrecision('-1e-1')");
assertException(function () {new BigNumber('12.345e1').toPrecision(Infinity)}, ".toPrecision(Infinity)");
assertException(function () {new BigNumber('12.345e1').toPrecision('-Infinity')}, ".toPrecision('-Infinity')");
BigNumber.config({ERRORS : false});
T('123', '12.345e1', BigNumber(3));
T('123.45', '12.345e1', null);
T('123.45', '12.345e1', undefined);
T('123.45', '12.345e1', NaN);
T('123.45', '12.345e1', 'NaN');
T('123.45', '12.345e1', []);
T('123.45', '12.345e1', {});
T('123.45', '12.345e1', '');
T('123.45', '12.345e1', ' ');
T('123.45', '12.345e1', 'hello');
T('123.45', '12.345e1', '\t');
T('123.45', '12.345e1', ' ');
T('123.45', '12.345e1', new Date);
T('123.45', '12.345e1', new RegExp);
T('123.4500', '12.345e1', 7.5);
T('123.45000000', '12.345e1', '1.1e1');
T('1e+2', '12.345e1', 1);
T('123.45', '12.345e1', '-1');
T('123.45', '12.345e1', -23);
T('123.45', '12.345e1', 1e9 + 1);
T('123.45', '12.345e1', 1e9 + 0.1);
T('123.45', '12.345e1', 0);
T('123.45', '12.345e1', '-0');
T('123.45', '12.345e1', 0.9);
T('123.45', '12.345e1', '-1e-1');
T('123.45', '12.345e1', Infinity);
T('123.45', '12.345e1', '-Infinity');
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];;
})(this.BigNumber);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

1104
test/toString.js Normal file

File diff suppressed because it is too large Load Diff

45
test/v8-LICENCE.txt Normal file
View File

@ -0,0 +1,45 @@
Some of the test cases in this directory are taken from the v8 source code
<http://code.google.com/p/v8/source/browse/> for which the licence is below.
2008: toPrecision.js
<http://code.google.com/p/v8/source/search?q=toPrecision&origq=toPrecision&btnG=Search+Trunk>
2010: abs.js pow.js
<http://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/math-pow.js?r=10133&spec=svn10133>
2011: ceil.js floor.js round.js
Licence
=======
Copyright 2008/2010/2011 the V8 project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.