Initial commit

pull/3/head
Michael Mclaughlin 11 years ago
commit b92f900a93

@ -0,0 +1 @@
test

@ -0,0 +1,23 @@
The MIT Expat Licence.
Copyright (c) 2014 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.

@ -0,0 +1,209 @@
![decimal.js](https://raw.githubusercontent.com/MikeMcl/decimal.js/gh-pages/decimaljs.png)
An arbitrary-precision Decimal type for JavaScript.
<br>
## Features
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
- Simple API but full-featured
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
- Includes a `toFraction` and correctly-rounded `exp`, `ln`, `log` and `sqrt` functions
- Supports non-integer powers (although performance is limited)
- Works with numbers with or without fraction digits in bases from 2 to 64 inclusive
- Stores values in an accessible decimal floating point format
- No dependencies
- Uses JavaScript 1.5 (ECMAScript 3) features only
- Comprehensive [documentation](http://mikemcl.github.io/decimal.js/) and test set
- 8 KB minified and gzipped
![API](https://raw.githubusercontent.com/MikeMcl/decimal.js/gh-pages/API.png)
The library is similar to [bignumber.js](https://github.com/MikeMcl/bignumber.js/), but here
precision is specified in terms of significant digits instead of decimal places, and all
calculations are rounded to the precision (similar to Python's decimal module) rather than just
those involving division.
This library also adds `exp`, `ln` and `log` functions, among others, and supports non-integer powers.
Another major difference is that this library enables multiple Decimal constructors to be created
each with their own configuration (e.g. precision and range). This is, however, a significantly
larger library than *bignumber.js* and the even smaller [big.js](https://github.com/MikeMcl/big.js/).
## Load
The library is the single JavaScript file *decimal.js* (or minified, *decimal.min.js*).
It can be loaded via a script tag in an HTML document for the browser
<script src='./relative/path/to/decimal.js'></script>
or as a CommonJS, [Node.js](http://nodejs.org) or AMD module using `require`.
For Node, put the *decimal.js* file into the same directory as the file that is requiring it and use
var Decimal = require('./decimal');
or put it in a *node_modules* directory within the directory and use `require('decimal')`.
The library is also available from the [npm](https://npmjs.org/) registry
$ npm install decimal.js
To load with AMD loader libraries such as [requireJS](http://requirejs.org/):
require(['decimal'], function(Decimal) {
// Use Decimal here in local scope. No global Decimal.
});
## 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 object, `Decimal`, the constructor of Decimal numbers.
It accepts a value of type number *(up to 15 significant digits only)*, string or Decimal.
x = new Decimal(123.4567)
y = new Decimal('123456.7e-3')
z = new Decimal(x)
x.equals(y) && y.equals(z) && x.equals(z) // true
A base from 2 to 36 inclusive can also be specified.
x = new Decimal(1011, 2) // '11'
y = new Decimal('zz.9', 36) // '1295.25'
z = x.plus(y) // '1306.25'
A Decimal is immutable in the sense that it is not changed by its methods.
0.3 - 0.1 // 0.19999999999999998
x = new Decimal(0.3)
x.minus(0.1) // '0.2'
x // '0.3'
The methods that return a Decimal can be chained.
x.dividedBy(y).plus(z).times(9).floor()
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').ceil()
Many method names 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 Decimal(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'
As mentioned above, multiple Decimal constructors can be created, each with their own independent
configuration which applies to all Decimal numbers created from it.
All calculations are rounded to the number of significant digits specified by the `precision` property
of a Decimal constructor and rounded using the rounding mode specified by the `rounding` property.
Decimal.config({ precision: 5, rounding: 4 })
D = Decimal.constructor() // constructor is a factory method
D.config({ precision: 10, rounding: 1 })
x = new Decimal(5)
y = new D(5)
x.div(3) // '1.6667'
y.div(3) // '1.666666666'
Decimal.precision // 5
D.precision // 10
Many of the methods of JavaScript's Math object are replicated as static methods of a Decimal constructor
Decimal.sqrt('6.98372465832e+9823') // '8.3568682281821340204e+4911'
Decimal.pow(2, 0.0979843) // '1.0702770511687781839'
There is a `toFraction` method with an optional *maximum denominator* argument
y = new Decimal(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 `Decimal` values.
x = new Decimal(NaN) // 'NaN'
y = new Decimal(Infinity) // 'Infinity'
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
The value of a Decimal is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
x = new Decimal(-123.456);
x.c // '1,2,3,4,5,6' coefficient (i.e. significand)
x.e // 2 exponent
x.s // -1 sign
For further information see the [API](http://mikemcl.github.io/decimal.js/) reference in the *doc* directory.
## Test
The *test* directory contains the test scripts for each method.
The tests can be run with Node or a browser.
To test a single method use, from a command-line shell in the root directory, for example
$ node test/toFraction
To test all the methods
$ node test/every-test
or
$ npm test
For the browser, see *single-test.html* and *every-test.html* in the *test/browser* directory,
## Build
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
npm install uglify-js -g
then
npm run build
will create *decimal.min.js*.
The *decimal.min.js* already present was created with *Microsoft Ajax Minifier 5.8*.
## Feedback
Open an issue, or email
Michael <a href='mailto:M8ch88l@gmail.com'>M8ch88l@gmail.com</a>
Many hours of work have gone into this library.
A [bitcoin](https://bitcoin.org/en/getting-started) donation would be gratefully received:
**1PjzRBjGJycti49AXTiKsdC4PRCnTbyUyf**
Thank you
## Licence
MIT Expat.
See LICENCE.
## Change Log
####1.0.0
* 02/04/2014 Initial release

File diff suppressed because it is too large Load Diff

2
decimal.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -0,0 +1,36 @@
{
"name": "decimal.js",
"description": "An arbitrary-precision Decimal type for JavaScript.",
"version": "1.0.0",
"keywords": [
"arbitrary",
"precision",
"arithmetic",
"big",
"number",
"decimal",
"float",
"biginteger",
"bigdecimal",
"bignumber",
"bigint",
"bignum"
],
"repository" : {
"type": "git",
"url": "https://github.com/MikeMcl/decimal.js.git"
},
"main": "decimal",
"author": {
"name": "Michael Mclaughlin",
"email": "M8ch88l@gmail.com"
},
"engines": {
"node": "*"
},
"license": "MIT",
"scripts": {
"test": "node ./test/every-test.js",
"build": "uglifyjs decimal.js -c -m -o decimal.min.js --preamble '/* decimal.js v1.0.0 https://github.com/MikeMcl/decimal.js/LICENCE */'"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing decimal.js</title>
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
<script src='../../decimal.js'></script>
</head>
<body>
<script>
var arr,
passed = 0,
total = 0,
i = 0,
start = +new Date(),
methods = [
'abs',
'baseIn',
'baseOut',
'ceil',
'cmp',
'config',
'constructor',
'div',
'divToInt',
'dpSd',
'exp',
'floor',
'intPow',
'isFiniteEtc',
'ln',
'log',
'log10',
'minAndMax',
'minus',
'mod',
'neg',
'plus',
'pow',
'random',
'round',
'sqrt',
'times',
'toDP',
'toExponential',
'toFixed',
'toFormat',
'toFraction',
'toInt',
'toNearest',
'toNumber',
'toPrecision',
'toStringEtc',
'trunc'
];
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 += 'Decimal TESTING<br>';
load();
</script>
</body>
</html>

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Testing decimal.js</title>
<style> body {font-family: monospace; font-size: 12px; line-height: 14px;}</style>
<script src='../../decimal.js'></script>
</head>
<body>
<script src='../abs.js'></script>
<!-- <script src='../baseIn.js'></script> -->
<!-- <script src='../baseOut.js'></script> -->
<!-- <script src='../ceil.js'></script> -->
<!-- <script src='../cmp.js'></script> -->
<!-- <script src='../config.js'></script> -->
<!-- <script src='../constructor.js'></script> -->
<!-- <script src='../div.js'></script> -->
<!-- <script src='../divToInt.js'></script> -->
<!-- <script src='../dpSd.js'></script> -->
<!-- <script src='../exp.js'></script> -->
<!-- <script src='../floor.js'></script> -->
<!-- <script src='../intPow.js'></script> -->
<!-- <script src='../isFiniteEtc.js'></script> -->
<!-- <script src='../ln.js'></script> -->
<!-- <script src='../log.js'></script> -->
<!-- <script src='../log10.js'></script> -->
<!-- <script src='../minAndMax.js'></script> -->
<!-- <script src='../minus.js'></script> -->
<!-- <script src='../mod.js'></script> -->
<!-- <script src='../neg.js'></script> -->
<!-- <script src='../plus.js'></script> -->
<!-- <script src='../pow.js'></script> -->
<!-- <script src='../random.js'></script> -->
<!-- <script src='../round.js'></script> -->
<!-- <script src='../sqrt.js'></script> -->
<!-- <script src='../times.js'></script> -->
<!-- <script src='../toDP.js'></script> -->
<!-- <script src='../toExponential.js'></script> -->
<!-- <script src='../toFixed.js'></script> -->
<!-- <script src='../toFormat.js'></script> -->
<!-- <script src='../toFraction.js'></script> -->
<!-- <script src='../toInt.js'></script> -->
<!-- <script src='../toNearest.js'></script> -->
<!-- <script src='../toNumber.js'></script> -->
<!-- <script src='../toPrecision.js'></script> -->
<!-- <script src='../toStringEtc.js'></script> -->
<!-- <script src='../trunc.js'></script> -->
</body>
</html>

@ -0,0 +1,258 @@
var count = (function ceil(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, n) {
assert(String(expected), new Decimal(String(value)).ceil(n).toString());
}
log('\n Testing ceil...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
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 Decimal('1.000000000000000000000000000000000000001').ceil());
// ---------------------------------------------------------------- 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);
Decimal.toExpNeg = -100;
Decimal.toExpPos = 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
assertException(function () {new Decimal('0.6').ceil(0)}, "ceil(0)");
assertException(function () {new Decimal('1.6').ceil(0)}, "ceil(0)");
T('0.7', '0.66', 1);
T('2', '1.66', 1);
T('0.6667', '0.66666', 4);
T('1.667', '1.66666', 4);
T('0.6', '0.6', 1);
T('2', '1.6', 1);
T('0.67', '0.666', 2);
T('1.7', '1.66', 2);
T('0.66667', '0.666666', 5);
T('1.6667', '1.66666', 5);
T('-1', '-1.0', 1);
T('-1', '-1.00001', 1);
T('-1', '-1.010203', 2);
T('-2.99', '-2.999', 3);
T('-0.0001', '-0.000123', 1);
T('-0.000123', '-0.000123', 4);
T('0.010203', '0.010203', 5);
T('0.0102031', '0.01020301', 6);
T('-9.999', '-9.999', 6);
T('-9.9999', '-9.999900000001', 6);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,590 @@
var count = (function config(Decimal) {
var start = +new Date(),
log,
error,
obj,
undefined,
passed = 0,
total = 0,
state,
T;
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
log('\n Testing config...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: false,
crypto: false,
modulo: 1
});
assert(
true,
Decimal.precision === 20 &&
Decimal.rounding === 4 &&
Decimal.toExpNeg === -7 &&
Decimal.toExpPos === 21 &&
Decimal.minE === -9e15 &&
Decimal.maxE === 9e15 &&
Decimal.errors === false &&
Decimal.crypto === false &&
Decimal.modulo === 1
);
Decimal.config({
precision: 40,
rounding : 4,
toExpNeg: -1000,
toExpPos: 1000,
minE: -1e9,
maxE: 1e9,
errors: true,
crypto: true,
modulo: 4
});
// Throw if no object is passed.
assertException(function () {Decimal.config()}, "config()");
assertException(function () {Decimal.config(undefined)}, "config(undefined)");
assertException(function () {Decimal.config(null)}, "config(null)");
assertException(function () {Decimal.config('')}, "config('')");
assertException(function () {Decimal.config('hi')}, "config('hi')");
assertException(function () {Decimal.config(4)}, "config(4)");
assert(true, Decimal.precision === 40);
assert(true, Decimal.rounding === 4);
assert(true, Decimal.toExpNeg === -1000);
assert(true, Decimal.toExpPos === 1000);
assert(true, Decimal.minE === -1e9);
assert(true, Decimal.maxE === 1e9);
assert(true, Decimal.errors === true);
assert(true, Decimal.crypto === true || Decimal.crypto === false);
assert(true, Decimal.modulo === 4);
Decimal.config({
toExpNeg: -7,
toExpPos: 21,
minE: -324,
maxE: 308
});
// precision
T = function (expected, obj) {
Decimal.config(obj);
assert(String(expected), String(Decimal.precision));
}
T(1, {precision: 1});
T(20, {precision: 20});
T(300000,{precision: 300000});
T(4e+8, {precision: 4e8});
T(123456789, {precision: '123456789'});
T(1e9, {precision: 1e9});
T(1e9, {precision: null});
T(1e9, {precision: undefined});
assertException(function () {Decimal.config({precision: -1})}, "precision: -1");
assertException(function () {Decimal.config({precision: 0.1})}, "precision: 0.1");
assertException(function () {Decimal.config({precision: 1.1})}, "precision: 1.1");
assertException(function () {Decimal.config({precision: -1.1})}, "precision: -1.1");
assertException(function () {Decimal.config({precision: 8.1})}, "precision: 8.1");
assertException(function () {Decimal.config({precision: 1e+9 + 1})}, "precision: 1e9 + 1");
assertException(function () {Decimal.config({precision: []})}, "precision: []");
assertException(function () {Decimal.config({precision: {}})}, "precision: {}");
assertException(function () {Decimal.config({precision: ''})}, "precision: ''");
assertException(function () {Decimal.config({precision: ' '})}, "precision: ' '");
assertException(function () {Decimal.config({precision: 'hi'})}, "precision: 'hi'");
assertException(function () {Decimal.config({precision: '1e+9'})}, "precision: '1e+9'");
assertException(function () {Decimal.config({precision: NaN})}, "precision: NaN");
assertException(function () {Decimal.config({precision: Infinity})}, "precision: Infinity");
Decimal.config({ errors: false });
T(1e9, {precision: -1});
T(1e9, {precision: 0.1});
T(1, {precision: 1.99});
T(1, {precision: -1.1});
T(8, {precision: 8.7654321});
T(8, {precision: 1e9 + 1});
T(8, {precision: []});
T(8, {precision: {}});
T(8, {precision: ''});
T(8, {precision: ' '});
T(8, {precision: 'hi'});
T(1e9, {precision: '1e+9'});
T(1e9, {precision: NaN});
T(1e9, {precision: Infinity});
T(1e9, {precision: new Date});
T(1e9, {precision: null});
T(1e9, {precision: undefined});
// rounding
T = function (expected) {
assert(expected, Decimal.rounding);
}
Decimal.config({ rounding: 8, errors: 0 });
Decimal.config({rounding: -1}); T(8);
Decimal.config({rounding: 0.1}); T(0);
Decimal.config({rounding: 1.99}); T(1);
Decimal.config({rounding: -1.1}); T(1);
Decimal.config({rounding: 8.01}); T(1);
Decimal.config({rounding: 7.99}); T(7);
Decimal.config({rounding: 1e9 + 1}); T(7);
Decimal.config({rounding: []}); T(7);
Decimal.config({rounding: {}}); T(7);
Decimal.config({rounding: ''}); T(7);
Decimal.config({rounding: ' '}); T(7);
Decimal.config({rounding: 'hi'}); T(7);
Decimal.config({rounding: '1e+0'}); T(1);
Decimal.config({rounding: NaN}); T(1);
Decimal.config({rounding: Infinity}); T(1);
Decimal.config({rounding: new Date}); T(1);
Decimal.config({rounding: null}); T(1);
Decimal.config({rounding: undefined}); T(1);
Decimal.config({ errors: true });
T = function (expected, rm) {
Decimal.config(rm);
assert(String(expected), String(Decimal.rounding));
}
T(0, {rounding: 0});
T(1, {rounding: 1});
T(2, {rounding: 2});
T(3, {rounding: 3});
T(4, {rounding: 4});
T(5, {rounding: 5});
T(6, {rounding: 6});
T(7, {rounding: 7});
T(8, {rounding: 8});
T(8, {rounding: null});
T(8, {rounding: undefined});
assertException(function () {Decimal.config({rounding: -1})}, "rounding : -1");
assertException(function () {Decimal.config({rounding: 0.1})}, "rounding : 0.1");
assertException(function () {Decimal.config({rounding: 1.1})}, "rounding : 1.1");
assertException(function () {Decimal.config({rounding: -1.1})}, "rounding : -1.1");
assertException(function () {Decimal.config({rounding: 8.1})}, "rounding : 8.1");
assertException(function () {Decimal.config({rounding: 9})}, "rounding : 9");
assertException(function () {Decimal.config({rounding: 11})}, "rounding : 11");
assertException(function () {Decimal.config({rounding: []})}, "rounding : []");
assertException(function () {Decimal.config({rounding: {}})}, "rounding : {}");
assertException(function () {Decimal.config({rounding: ''})}, "rounding : ''");
assertException(function () {Decimal.config({rounding: ' '})}, "rounding : ' '");
assertException(function () {Decimal.config({rounding: 'hi'})}, "rounding : 'hi'");
assertException(function () {Decimal.config({rounding: NaN})}, "rounding : NaN");
assertException(function () {Decimal.config({rounding: Infinity})}, "rounding : Infinity");
// toExpNeg, toExpPos
assert(true, Decimal.toExpNeg === -7);
assert(true, Decimal.toExpPos === 21);
assertException(function () {Decimal.config({toExpNeg: 0.1})}, "toExpNeg: 0.1");
assertException(function () {Decimal.config({toExpPos: -0.1})}, "toExpPos: -0.1");
assertException(function () {Decimal.config({toExpNeg: 1})}, "toExpNeg: 1");
assertException(function () {Decimal.config({toExpPos: -1})}, "toExpPos: -1");
assertException(function () {Decimal.config({toExpNeg: 1e9 + 1})}, "toExpNeg: 1e9 + 1");
assertException(function () {Decimal.config({toExpPos: -1e9 - 1})}, "toExpPos: -1e9 - 1");
assertException(function () {Decimal.config({toExpNeg: Infinity})}, "toExpNeg: Infinity");
assertException(function () {Decimal.config({toExpPos: -Infinity})}, "toExpPos: -Infinity");
assert(true, Decimal.toExpNeg === -7);
assert(true, Decimal.toExpPos === 21);
Decimal.config({toExpNeg: -1});
assert(-1, Decimal.toExpNeg);
Decimal.config({toExpPos: 1});
assert(1, Decimal.toExpPos);
Decimal.config({toExpNeg: 0});
assert(true, Decimal.toExpNeg === 0);
assert(false, Decimal.toExpPos === 0);
Decimal.config({toExpNeg: -1});
assert(true, Decimal.toExpNeg === -1 && Decimal.toExpPos !== -1);
Decimal.config({ errors: true });
// minE, maxE
assert(true, Decimal.minE === -324);
assert(true, Decimal.maxE === 308);
assertException(function () {Decimal.config({minE: -0.9})}, "minE: -0.9");
assertException(function () {Decimal.config({maxE: 0.9})}, "maxE: 0.9");
assertException(function () {Decimal.config({maxE: -1})}, "maxE: -1");
assertException(function () {Decimal.config({minE: 1})}, "minE: 1");
assertException(function () {Decimal.config({minE: -9e16})}, "minE: -9e16");
assertException(function () {Decimal.config({maxE: -1e9})}, "maxE: -1e9");
assertException(function () {Decimal.config({minE: 1e9})}, "minE: 1e9");
assertException(function () {Decimal.config({maxE: 9e16})}, "maxE: 9e16");
assertException(function () {Decimal.config({minE: Infinity})}, "minE: Infinity");
assertException(function () {Decimal.config({maxE: Infinity})}, "maxE: Infinity");
assertException(function () {Decimal.config({minE: "-Infinity"})}, "minE: '-Infinity'");
assertException(function () {Decimal.config({maxE: "-Infinity"})}, "maxE: '-Infinity'");
assert(true, Decimal.minE === -324);
assert(true, Decimal.maxE === 308);
Decimal.config({minE: -1});
assert(true, Decimal.minE === -1 && Decimal.maxE !== 1);
Decimal.config({maxE: 1});
assert(true, Decimal.minE !== 1 && Decimal.maxE === 1);
// errors
Decimal.config({errors: 0});
assert(false, Decimal.errors);
Decimal.config({errors: 1});
assert(true, Decimal.errors);
Decimal.config({errors: false});
assert(false, Decimal.errors);
Decimal.config({errors: true});
assert(true, Decimal.errors);
Decimal.config({errors: null});
assert(true, Decimal.errors);
Decimal.config({errors: undefined});
assert(true, Decimal.errors);
assertException(function () {Decimal.config({errors: 'hiya'})}, "errors: 'hiya'");
assertException(function () {Decimal.config({errors: 'true'})}, "errors: 'true'");
assertException(function () {Decimal.config({errors: 'false'})}, "errors: 'false'");
assertException(function () {Decimal.config({errors: '0'})}, "errors: '0'");
assertException(function () {Decimal.config({errors: '1'})}, "errors: '1'");
assertException(function () {Decimal.config({errors: -1})}, "errors: -1");
assertException(function () {Decimal.config({errors: 0.1})}, "errors: 0.1");
assertException(function () {Decimal.config({errors: 1.1})}, "errors: 1.1");
assertException(function () {Decimal.config({errors: []})}, "errors: []");
assertException(function () {Decimal.config({errors: {}})}, "errors: {}");
assertException(function () {Decimal.config({errors: ''})}, "errors: ''");
assertException(function () {Decimal.config({errors: ' '})}, "errors: ' '");
assertException(function () {Decimal.config({errors: NaN})}, "errors: NaN");
assertException(function () {Decimal.config({errors: Infinity})}, "errors: Infinity");
assert(true, Decimal.errors);
Decimal.config({ errors: false });
T = function (expected, err) {
Decimal.config(err);
assert(String(expected), String(Decimal.errors));
}
T(false, {errors: null});
T(false, {errors: undefined});
T(false, {errors: NaN});
T(false, {errors: 'd'});
T(false, {errors: []});
T(false, {errors: {}});
T(false, {errors: new Date});
T(true, {errors: Boolean(1)});
T(true, {errors: Boolean(true)});
T(false, {errors: Boolean(0)});
T(false, {errors: Boolean(false)});
T(true, {errors: Boolean('false')});
// crypto
T = function (expected, obj) {
Decimal.config(obj);
assert(String(expected), String(Decimal.crypto));
}
Decimal.config({ crypto: true });
state = Decimal.crypto;
assertException(function () {Decimal.config({crypto: 'hiya'})}, "crypto: 'hiya'");
assertException(function () {Decimal.config({crypto: 'true'})}, "crypto: 'true'");
assertException(function () {Decimal.config({crypto: 'false'})}, "crypto: 'false'");
assertException(function () {Decimal.config({crypto: '0'})}, "crypto: '0'");
assertException(function () {Decimal.config({crypto: '1'})}, "crypto: '1'");
assertException(function () {Decimal.config({crypto: -1})}, "crypto: -1");
assertException(function () {Decimal.config({crypto: 0.1})}, "crypto: 0.1");
assertException(function () {Decimal.config({crypto: 1.1})}, "crypto: 1.1");
assertException(function () {Decimal.config({crypto: []})}, "crypto: []");
assertException(function () {Decimal.config({crypto: {}})}, "crypto: {}");
assertException(function () {Decimal.config({crypto: ''})}, "crypto: ''");
assertException(function () {Decimal.config({crypto: ' '})}, "crypto: ' '");
assertException(function () {Decimal.config({crypto: NaN})}, "crypto: NaN");
assertException(function () {Decimal.config({crypto: Infinity})}, "crypto: Infinity");
Decimal.config({ errors: false });
T(state, {crypto: null});
T(state, {crypto: undefined});
T(state, {crypto: NaN});
T(state, {crypto: 'd'});
T(state, {crypto: []});
T(state, {crypto: {}});
T(state, {crypto: new Date});
T(state, {crypto: Boolean(1)});
T(state, {crypto: Boolean(true)});
T(false, {crypto: Boolean(0)});
T(false, {crypto: Boolean(false)});
T(state, {crypto: Boolean('false')});
T(false, {crypto: false});
T(state, {crypto: 1});
T(false, {crypto: 0});
T(state, {crypto: true});
// modulo
Decimal.config({ errors: true });
T = function (expected, rm) {
Decimal.config(rm);
assert(String(expected), String(Decimal.modulo));
}
T(0, {modulo: 0});
T(1, {modulo: 1});
T(2, {modulo: 2});
T(3, {modulo: 3});
T(4, {modulo: 4});
T(5, {modulo: 5});
T(6, {modulo: 6});
T(7, {modulo: 7});
T(8, {modulo: 8});
T(9, {modulo: 9});
T(9, {modulo: null});
T(9, {modulo: undefined});
assertException(function () {Decimal.config({modulo: -1})}, "modulo: -1");
assertException(function () {Decimal.config({modulo: 0.1})}, "modulo: 0.1");
assertException(function () {Decimal.config({modulo: 1.1})}, "modulo: 1.1");
assertException(function () {Decimal.config({modulo: -1.1})}, "modulo: -1.1");
assertException(function () {Decimal.config({modulo: 8.1})}, "modulo: 8.1");
assertException(function () {Decimal.config({modulo: 10})}, "modulo: 10");
assertException(function () {Decimal.config({modulo: -11})}, "modulo: -11");
assertException(function () {Decimal.config({modulo: []})}, "modulo: []");
assertException(function () {Decimal.config({modulo: {}})}, "modulo: {}");
assertException(function () {Decimal.config({modulo: ''})}, "modulo: ''");
assertException(function () {Decimal.config({modulo: ' '})}, "modulo: ' '");
assertException(function () {Decimal.config({modulo: 'hi'})}, "modulo: 'hi'");
assertException(function () {Decimal.config({modulo: NaN})}, "modulo: NaN");
assertException(function () {Decimal.config({modulo: Infinity})}, "modulo: Infinity");
assert(9, Decimal.modulo);
// Test constructor parsing.
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: true,
crypto: false,
modulo: 1
});
T = function (expected, n) {
assert(String(expected), String(new Decimal(n).toString()));
}
T('123.456789', 123.456789);
T('123.456789', '123.456789');
var N = 'NaN';
T(N, NaN);
T(N, 'NaN');
T(N, ' NaN');
T(N, 'NaN ');
T(N, ' NaN ');
T(N, '+NaN');
T(N, ' +NaN');
T(N, '+NaN ');
T(N, ' +NaN ');
T(N, '-NaN');
T(N, ' -NaN');
T(N, '-NaN ');
T(N, ' -NaN ');
assertException(function () {new Decimal('+ NaN')}, "+ NaN");
assertException(function () {new Decimal('- NaN')}, "- NaN");
assertException(function () {new Decimal(' + NaN')}, " + NaN");
assertException(function () {new Decimal(' - NaN')}, " - NaN");
assertException(function () {new Decimal('. NaN')}, ". NaN");
assertException(function () {new Decimal('.-NaN')}, ".-NaN");
assertException(function () {new Decimal('.+NaN')}, ".+NaN");
assertException(function () {new Decimal('-.NaN')}, "-.NaN");
assertException(function () {new Decimal('+.NaN')}, "+.NaN");
var I = 'Infinity';
T(I, Infinity);
T(I, 'Infinity');
T(I, ' Infinity');
T(I, 'Infinity ');
T(I, ' Infinity ');
T(I, '+Infinity');
T(I, ' +Infinity');
T(I, '+Infinity ');
T(I, ' +Infinity ');
T('-Infinity', '-Infinity');
T('-Infinity', ' -Infinity');
T('-Infinity', '-Infinity ');
T('-Infinity', ' -Infinity ');
assertException(function () {new Decimal('+ Infinity')}, "+ Infinity");
assertException(function () {new Decimal(' + Infinity')}, " + Infinity");
assertException(function () {new Decimal('- Infinity')}, "- Infinity");
assertException(function () {new Decimal(' - Infinity')}, " - Infinity");
assertException(function () {new Decimal('.Infinity')}, ".Infinity");
assertException(function () {new Decimal('. Infinity')}, ". Infinity");
assertException(function () {new Decimal('.-Infinity')}, ".-Infinity");
assertException(function () {new Decimal('.+Infinity')}, ".+Infinity");
assertException(function () {new Decimal('-.Infinity')}, "-.Infinity");
assertException(function () {new Decimal('+.Infinity')}, "+.Infinity");
var Z = '0';
T(Z, 0);
T(Z, -0);
T(Z, '.0');
T(Z, '0.');
T(Z, '0.00000000');
T(Z, '-0.');
T(Z, '+0.');
T(Z, '+0');
T(Z, '-0');
T(Z, ' +0');
T(Z, ' -0');
T(Z, ' +0 ');
T(Z, ' -0 ');
T(Z, '+.0');
T(Z, '-.0');
T(Z, ' +.0');
T(Z, ' -.0');
T(Z, ' +.0 ');
T(Z, ' -.0 ');
assertException(function () {new Decimal('+-0')}, "+-0");
assertException(function () {new Decimal('-+0')}, "-+0");
assertException(function () {new Decimal('--0')}, "--0");
assertException(function () {new Decimal('++0')}, "++0");
assertException(function () {new Decimal('.-0')}, ".-0");
assertException(function () {new Decimal('.+0')}, ".+0");
assertException(function () {new Decimal('0 .')}, "0 .");
assertException(function () {new Decimal('. 0')}, ". 0");
assertException(function () {new Decimal('..0')}, "..0");
assertException(function () {new Decimal('+.-0')}, "+.-0");
assertException(function () {new Decimal('-.+0')}, "-.+0");
assertException(function () {new Decimal('+. 0')}, "+. 0");
assertException(function () {new Decimal('-. 0')}, "-. 0");
T('2', '+2');
T('-2', '-2');
T('2', ' +2');
T('-2', ' -2');
T('2', ' +2 ');
T('-2', ' -2 ');
T('0.2', '.2');
T('2', '2.');
T('-2', '-2.');
T('2', '+2.');
T('0.2', '+.2');
T('-0.2', '-.2');
T('0.2', ' +.2');
T('-0.2', ' -.2');
T('0.2', ' +.2 ');
T('-0.2', ' -.2 ');
assertException(function () {new Decimal('+-2')}, "+-2");
assertException(function () {new Decimal('-+2')}, "-+2");
assertException(function () {new Decimal('--2')}, "--2");
assertException(function () {new Decimal('++2')}, "++2");
assertException(function () {new Decimal('.-2')}, ".-2");
assertException(function () {new Decimal('.+2')}, ".+2");
assertException(function () {new Decimal('2 .')}, "2 .");
assertException(function () {new Decimal('. 2')}, ". 2");
assertException(function () {new Decimal('..2')}, "..2");
assertException(function () {new Decimal('+.-2')}, "+.-2");
assertException(function () {new Decimal('-.+2')}, "-.+2");
assertException(function () {new Decimal('+. 2')}, "+. 2");
assertException(function () {new Decimal('-. 2')}, "-. 2");
assertException(function () {new Decimal('+2..')}, "+2..");
assertException(function () {new Decimal('-2..')}, "-2..");
assertException(function () {new Decimal('-.2.')}, "-.2.");
assertException(function () {new Decimal('+.2.')}, "+.2.");
assertException(function () {new Decimal('.-20.')}, ".-20.");
assertException(function () {new Decimal('.+20.')}, ".+20.");
assertException(function () {new Decimal('. 20.')}, ". 20.");
assertException(function () {new Decimal(undefined)}, "undefined");
assertException(function () {new Decimal([])}, "[]");
assertException(function () {new Decimal('')}, "''");
assertException(function () {new Decimal(null)}, "null");
assertException(function () {new Decimal(' ')}, "' '");
assertException(function () {new Decimal('nan')}, "nan");
assertException(function () {new Decimal('23er')}, "23er");
assertException(function () {new Decimal('e4')}, "e4");
assertException(function () {new Decimal('0x434')}, "0x434");
assertException(function () {new Decimal('--45')}, "--45");
assertException(function () {new Decimal('+-2')}, "+-2");
assertException(function () {new Decimal('0 0')}, "0 0");
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,133 @@
var count = (function constructor(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 constructor...');
Decimal.config({
precision: 10,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: true
});
var D1 = Decimal.constructor({ precision: 1 });
var D2 = Decimal.constructor({ precision: 2 });
var D3 = Decimal.constructor({ precision: 3 });
var D4 = Decimal.constructor({ precision: 4 });
var D5 = Decimal.constructor({ precision: 5 });
var D6 = Decimal.constructor({ precision: 6 });
var D7 = Decimal.constructor({ precision: 7 });
var D8 = Decimal.constructor();
D8.config({ precision: 8 });
var D9 = Decimal.constructor({ precision: 9 });
assert(true, Decimal.prototype === D9.prototype);
assert(false, Decimal === D9);
var x = new Decimal(5);
var x1 = new D1(5);
var x2 = new D2(5);
var x3 = new D3(5);
var x4 = new D4(5);
var x5 = new D5(5);
var x6 = new D6(5);
var x7 = new D7(5);
var x8 = new D8(5);
var x9 = new D9(5);
assert(true, x1.div(3).eq(2));
assert(true, x2.div(3).eq(1.7));
assert(true, x3.div(3).eq(1.67));
assert(true, x4.div(3).eq(1.667));
assert(true, x5.div(3).eq(1.6667));
assert(true, x6.div(3).eq(1.66667));
assert(true, x7.div(3).eq(1.666667));
assert(true, x8.div(3).eq(1.6666667));
assert(true, x9.div(3).eq(1.66666667));
assert(true, x.div(3).eq(1.666666667));
var y = new Decimal(3);
var y1 = new D1(3);
var y2 = new D2(3);
var y3 = new D3(3);
var y4 = new D4(3);
var y5 = new D5(3);
var y6 = new D6(3);
var y7 = new D7(3);
var y8 = new D8(3);
var y9 = new D9(3);
assert(true, x1.div(y1).eq(2));
assert(true, x2.div(y2).eq(1.7));
assert(true, x3.div(y3).eq(1.67));
assert(true, x4.div(y4).eq(1.667));
assert(true, x5.div(y5).eq(1.6667));
assert(true, x6.div(y6).eq(1.66667));
assert(true, x7.div(y7).eq(1.666667));
assert(true, x8.div(y8).eq(1.6666667));
assert(true, x9.div(y9).eq(1.66666667));
assert(true, x.div(y).eq(1.666666667));
assert(true, x1.div(y9).eq(2));
assert(true, x2.div(y8).eq(1.7));
assert(true, x3.div(y7).eq(1.67));
assert(true, x4.div(y6).eq(1.667));
assert(true, x5.div(y5).eq(1.6667));
assert(true, x6.div(y4).eq(1.66667));
assert(true, x7.div(y3).eq(1.666667));
assert(true, x8.div(y2).eq(1.6666667));
assert(true, x9.div(y1).eq(1.66666667));
assert(true, Decimal.precision == 10);
assert(true, D9.precision == 9);
assert(true, D8.precision == 8);
assert(true, D7.precision == 7);
assert(true, D6.precision == 6);
assert(true, D5.precision == 5);
assert(true, D4.precision == 4);
assert(true, D3.precision == 3);
assert(true, D2.precision == 2);
assert(true, D1.precision == 1);
assert(false, new Decimal(9.99).eq(new D3('-9.99')));
assert(true, new Decimal(9.99).eq(new D5('9.99')));
assert(false, new Decimal(123.456789).round().eq(new D3('123.456789').round()));
assert(true, new Decimal(123.456789).round(5).eq(new D3('123.456789').round(5)));
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,96 @@
var count = (function dpSd(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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(value, dp, sd, zs) {
assert(dp, new Decimal(value).dp());
assert(sd, new Decimal(value).sd(zs));
//assert(dp, new Decimal(value).decimalPlaces());
//assert(sd, new Decimal(value).precision(zs));
}
log('\n Testing decimalPlaces and precision...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: true
});
T(0, 0, 1);
T(-0, 0, 1);
T(NaN, null, null);
T(Infinity, null, null);
T(-Infinity, null, null);
T(1, 0, 1);
T(-1, 0, 1);
T(100, 0, 1);
T(100, 0, 1, 0);
T(100, 0, 1, false);
T(100, 0, 3, 1);
T(100, 0, 3, true);
T('0.0012345689', 10, 8);
T('0.0012345689', 10, 8, 0);
T('0.0012345689', 10, 8, false);
T('0.0012345689', 10, 8, 1);
T('0.0012345689', 10, 8, true);
T('987654321000000.0012345689000001', 16, 31, 0);
T('987654321000000.0012345689000001', 16, 31, 1);
T('1e+123', 0, 1);
T('1e+123', 0, 124, 1);
T('1e-123', 123, 1);
T('1e-123', 123, 1);
T('1e-123', 123, 1, 1);
T('9.9999e+9000000000000000', 0, 5, false);
T('9.9999e+9000000000000000', 0, 9000000000000001, true);
T('-9.9999e+9000000000000000', 0, 5, false);
T('-9.9999e+9000000000000000', 0, 9000000000000001, true);
T('1e-9000000000000000', 9e15, 1, false);
T('1e-9000000000000000', 9e15, 1, true);
T('-1e-9000000000000000', 9e15, 1, false);
T('-1e-9000000000000000', 9e15, 1, true);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,102 @@
var arr,
passed = 0,
total = 0,
start = +new Date();
console.log( '\n STARTING TESTS...\n' );
[
'abs',
'baseIn',
'baseOut',
'ceil',
'cmp',
'config',
'constructor',
'div',
'divToInt',
'dpSd',
'exp',
'floor',
'intPow',
'isFiniteEtc',
'ln',
'log',
'log10',
'minAndMax',
'minus',
'mod',
'neg',
'plus',
'pow',
'random',
'round',
'sqrt',
'times',
'toDP',
'toExponential',
'toFixed',
'toFormat',
'toFraction',
'toInt',
'toNearest',
'toNumber',
'toPrecision',
'toStringEtc',
'trunc'
]
.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' );

@ -0,0 +1,592 @@
var count = (function exp(Decimal) {
var start = +new Date(),
sum,
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
function T(arg, expected, pr, rm) {
total++;
Decimal.rounding = rm;
Decimal.precision = pr;
var actual = new Decimal(arg).exp().toString();
//if ( total % 100 == 0 ) log( total);
if ( expected !== actual ) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
error(' precision: ' + pr );
error(' rm: ' + ['UP', 'DOWN', 'CEIL', 'FLOOR', 'HALF_UP', 'HALF_DOWN', 'HALF_EVEN'][rm]);
log('');
//process.exit();
} else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
log('\n Testing exp...');
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
T('0', '1', 40, 4);
T('0', String(Math.exp(0)), 40, 4);
T('-0', '1', 40, 4);
T('-0', String(Math.exp(-0)), 40, 4);
T('Infinity', 'Infinity', 40, 4);
T('Infinity', String(Math.exp(Infinity)), 40, 4);
T('-Infinity', '0', 40, 4);
T('-Infinity', String(Math.exp(-Infinity)), 40, 4);
T('NaN', 'NaN', 40, 4);
T('NaN', String(Math.exp(NaN)), 40, 4);
T('1', '2.718281828459045235360287471352662497757', 40, 4);
T('4.504575', '90.42990317191332252519829', 25, 5);
T('6.3936622751479561979', '598.04277120550571020949043340838952845520759628012', 50, 4);
T('0.000000000000000004', '1.000000000000000004000000000000000008001', 40, 2);
T('0.9', '2.45960311115694966380012656360247069542177230644', 48, 1);
T('-0.0000000000000005', '0.999999999999999500000000000000124', 33, 1);
T('-0.00000000000000000001', '0.99999999999999999999000000000000000000004999', 44, 3);
T('-0.000000000000004', '0.999999999999996000000000000008', 31, 0);
T('-0.0000000000000000006', '0.99999', 5, 3);
T('0.0000000000000000006', '1', 5, 3);
T('-0.0000003', '1', 1, 4);
// Exponent estimate incorrect by -1.
T('20.72326583694641116', '1000000000.0000000038', 20, 1);
// Exponent estimate incorrect by +1.
T('-27.6310211159285483', '0.000000000000999', 3, 1);
T('-0.9', '0.40656965974059911188345423964562', 32, 1);
T('-0.00000000000005', '0.999', 3, 3);
T('-0.9999999999999999', '0.367879441171442358383467887305694866395394004', 45, 4);
T('-0.99999', '0.36788311998424806939070532012638041', 35, 3);
T('-0.00000000001', '0.99999999999000000000004999999999983333333333375', 49, 2);
T('-0.9999999999999', '0.367879441171479109539640916233017625680100198337', 48, 0);
T('-0.999999999', '0.36787944153932176295090581241', 29, 0);
T('-0.0000000003', '0.9999999997000000001', 19, 2);
T('-0.0000001', '0.99999990000000499999983333333749999991667', 41, 2);
T('-0.0000000000000001', '0.9999999999999999', 26, 1);
T('-0.999999999999999', '0.36788', 5, 2);
T('-0.999999999', '0.367879441539321762951', 21, 4);
T('-0.000000000001', '0.9999999999990000000000005', 31, 0);
T('-0.1', '0.9048374180359595731642491', 25, 0);
T('-0.99999999', '0.36787944485', 12, 3);
T('-0.99999999', '0.36787944485023675170391910600205499737', 38, 0);
T('-0.1', '0.9048374180359595731642491', 25, 0);
T('-0.9', '0.4065696597', 10, 3);
T('-0.9999999999999', '0.367879441171479', 15, 3);
T('-0.99', '0.371576691022045690531524119908201386918028', 42, 3);
T('-0.999999999999999', '0.3678794411714426894749649417', 28, 0);
T('-0.9', '0.4', 2, 1);
T('-0.00000000009', '0.99999', 5, 1);
T('0.9', '2.45960311115694966380012656360247069542177230644', 48, 1);
T('40.95984262795251', '614658133673303019.41715', 23, 1);
T('50.57728', '9234930123395249855007.64784227728909958776637', 45, 0);
T('-9.295952106254287693', '0.00009179505707794839996147521992', 28, 3);
T('24.429', '40679902037.5', 12, 1);
T('3.085347', '21.875056169741656067', 20, 2);
T('6.079163', '436.663554324263441178', 21, 0);
T('0.89588138', '2.4494937731', 11, 5);
T('3.06', '21.3', 3, 4);
T('0.828620743', '2.2901578446832146', 17, 6);
T('0.8747', '2.39815573', 9, 1);
T('4', '54.5', 3, 3);
T('1.74023', '5.698653962365493026791', 22, 3);
T('0.3178134', '1.37411982654', 12, 5);
T('1.0212228', '2.77658790066265475', 18, 0);
T('2.8', '16.444646771097049871498016', 26, 6);
T('2', '7.389', 5, 1);
T('2.13349', '8.44428600324102919', 19, 1);
T('1.0306766', '2.8029617', 8, 4);
T('1.38629371', '3.99999739553', 12, 0);
T('2.140864956', '8.5', 2, 4);
T('1', '2.7182818284590452353602874713', 29, 1);
T('2.8', '16.4446467711', 13, 4);
T('1.7923271', '6.0034067514286690274238254973', 29, 0);
T('2', '7.38905609893065', 15, 4);
T('1.839758663', '6.2950188567239', 14, 1);
T('3.1541', '23.4319388536798', 15, 3);
T('6.23103', '508.27874', 8, 1);
T('0.15', '1.16183424272828312261663', 24, 0);
T('3.6454', '38.298089', 8, 4);
T('2.8086602', '16.5877', 6, 2);
T('1', '2.71828182845904523536', 22, 4);
T('3.712', '40.9355959021562903', 19, 2);
T('1.742336005', '5.71066800248', 12, 5);
T('1.94829406', '7.0167073', 8, 4);
T('4.53792106', '93.49622', 7, 6);
T('6.64122444', '766.032379703051467163', 22, 5);
T('0.59', '1.8039884153978569', 17, 4);
T('1.069', '2.912466', 7, 5);
T('5.47', '237.460192761166777', 18, 6);
T('1', '2.7182818284590452353602874', 26, 3);
T('1.05262', '2.8651479805939498363151', 23, 4);
T('2', '7.3890560989307', 14, 0);
T('0.770663108', '2.161198887', 10, 1);
T('3.10396411', '22.28612104395503868020057367', 28, 2);
T('0.070843718', '1.0734134', 8, 1);
T('3.16756', '23.74', 4, 3);
T('3.09319', '22.047296794', 12, 4);
T('4.22287929', '68.229654700624870971', 20, 0);
T('0.049', '1.050220350740028148477052382', 28, 6);
T('2.979', '19.668138', 8, 1);
T('2.16997957', '8.75810511', 9, 1);
T('2.28877132', '9.86281199356347203004036437', 27, 6);
T('4.194', '66.29', 4, 5);
T('5.91', '368.70615540935695963731067791320655388190326', 44, 1);
T('-5.902609', '0.00273230692267056246438147723389194384', 36, 2);
T('2.51702817133177045', '12.391715832605823799395356049382091406182442225751401702194', 59, 6);
T('-5.3248998735809373', '0.00486883848918771313614028943', 27, 5);
T('86.0308014196048618', '23051666630029629891752615873650659516.8', 39, 5);
T('82.80005620234729889', '911186989442424636345046399000294573.16', 38, 4);
T('-42.42', '0.0000000000000000003777705319209947865643111962982101072978098117086239', 52, 5);
T('60.521486473024083703969', '200000000000000000000000000', 2, 0);
T('-4.17474993628772754887607024407', '0.015379036913283326051932', 23, 6);
T('5.15848192994892205', '173.900262343770154193777636990155123', 36, 4);
T('48.51280530953109845281121', '1171773433869775271496.705353549248239249', 40, 4);
T('-83.31692810858358074846', '0.00000000000000000000000000000000000065', 2, 6);
T('5.0', '148.41315910257661', 17, 0);
T('-26.157235080322', '0.000000000004365732710654570876745768055064377', 34, 6);
T('4.839', '126.3429455919875779876042641029434173522444372921366', 52, 0);
T('0.49', '1.63231621995537897012241', 24, 3);
T('-7.00103148362379565132988', '0.00091094185917573214870501234047096488410149985981648084', 53, 1);
T('-39.650608828557189278296702', '0.0000000000000000060250323299891995263128384036579347198767321183', 47, 0);
T('7.85808372', '2586.559051908298187507224798651134032', 37, 5);
T('-25.4986333', '0.000000000008434983972929977172646073526', 28, 5);
T('-0.303041962020968342', '0.738568103909971139152808715117610617846094274382929416993', 58, 5);
T('10.472755756976268129267', '35339.47029633505016404775786755427053', 37, 6);
T('1.524289787555734346062054445', '5', 1, 5);
T('-3.32', '0.0361528317540464190553217816871620314298225205616', 48, 3);
T('2.857520575008267515709626', '17.418286018757914', 17, 1);
T('-60.878327095631005', '0.00000000000000000000000000363813218954008631796290164687837', 33, 1);
T('6.250931474675900676', '518.49556529174126624424204821981669896', 38, 4);
T('-5.254191', '0.00522557207022572211145726388606', 30, 2);
T('73.6006591118691311536', '92121312451766132662051939400000', 27, 5);
T('67.0234090932359557332', '129000000000000000000000000000', 3, 2);
T('6.4350484439574', '623.3127778698531510658792212713024749828103299', 46, 3);
T('-90.6147801309103528', '0.0000000000000000000000000000000000000004430992452392223286671364132586', 31, 0);
T('52.6735295600', '75131702520984694212520.839', 26, 5);
T('4.91754742409', '136.667015585278752656929641054712859399847337855456678258883', 60, 0);
T('-8.291786018917236430647515856', '0.0002505', 4, 3);
//T('-78.03021995', '0.00000000000000000000000000000000012939159130723785626819625049185391066817380332355631249360200246949630969671500298529462669748895678232581244175004509555737871158164223260482581933406189750840064313874290525472150304', 185, 2);
//T('-65.5697', '0.00000000000000000000000000003337652437455562867073994751282372838994769667915347141869977866029382739578532846650664126707722701801316210471349464487191237181322988487166228369151950649514595392574324567119830354411963426', 193, 5);
//T('0.96430545924571', '2.62296526741079188717419416037670893092556438984286053788563773704812088645688785151143663574250042985145383111131544859879755', 126, 6);
//T('60.1451295803099', '132037681591763789045100900.6939187978126186891786471239491104148439035633584291177021254669438544553160555103733290585', 118, 6);
//T('8.906696112088566691635215334442', '7381.233998522082693862325039489266505109300425685385103444940108779932106425752592429084345836417728790308900023992044559', 121, 5);
//T('-7.6361617319741493', '0.00048267754692256448785514689616329113897932837215780936160152445059198141566339654670119718101507', 95, 3);
//T('2.2847262734631786625993104', '9.822997041022537939460657363745567812129850509193830846260108728127774226066405012998851925020414630467970448731497809048192183655220296245719654252789298101900175713452', 169, 4);
//T('-1.751068587', '0.173588350052541809092671571396485290831945336467484513092245615654671658593803202983882869040826121983204816598516666763555817201006319488674783046', 147, 6);
//T('-56.121971', '0.0000000000000000000000004231922260123080225416084760213136093584213955067689036101877712291906545157435155523987472402', 94, 6);
//T('-57.690414043058125421322186594', '0.00000000000000000000000008818028992320569897455339220986133154974823015862849888226359090922324890216749325639317431725311012337973785711517060848693072713095743058979757475602435590352812393443910956397581939545729', 190, 0);
//T('-47.1', '0.00000000000000000000350533801181874441811469677551581468577709830105775954176554434690403590610547218351841339269315144253721986305449170234760309378200184804357833', 144, 5);
//T('-65.47337667', '0.0000000000000000000000000000367513926368590248765223057526457211208181074386730408507383748728330232411422736130730332078225570932897797438984308803608', 123, 2);
Decimal.toExpNeg = Decimal.toExpPos = 0;
// Max integer argument
T('20723265836946413', '6.3207512951460243608e+9000000000000000', 20, 4);
// Min integer argument
T('-20723265836946411', '1.1690154783664756563e-9000000000000000', 20, 4);
T('2.08E+16', 'Infinity', 10, 1);
T('9.99999999e+9000000000000000', 'Infinity', 100, 4);
T('-2.08E+16', '0e+0', 10, 1);
T('1e-9000000000000000', '1e+0', 10, 1);
// Exponent estimate incorrect by +1.
T('2302585095.29663062096', '9.999998439e+1000000000', 10, 1);
// Exponent estimate incorrect by -1.
T('557.22559250455906', '1.0000000000000044e+242', 17, 1);
T('-7.2204571E-4550853476128405', '9.99999e-1', 6, 1);
T('-1.239848698043325450682384840', '2.894280056499551869832955260486309228756785711877e-1', 49, 2);
T('-358219354.0214584957674057041104824439823073474823', '1.7279578060422445345064581640966e-155572689', 32, 3);
T('8.82661445434039879925209590467500361019097244359748402', '6.813181388774733211e+3', 19, 6);
T('9.02366224E-9', '1.00000000902366228071324023326175156155718e+0', 43, 6);
T('-4.4768686752786086271180252E+574398129049502', '0e+0', 15, 3);
T('6.75038673622177', '8.54389121861983647815713666082881938951322130680514e+2', 51, 0);
T('4398.97294167362710274034929973848797228', '2.81e+1910', 3, 1);
T('-1484825.49833369444515197353', '3.01636873384e-644852', 12, 4);
T('0.065440317047917450552572898380917566295', '1.0676290161605702e+0', 17, 3);
T('-5901709079.09', '1.421971806677231650130742690252423304677744948915688926e-2563079687', 55, 6);
T('-86163.294461', '5.71048483678681595944539134785275858233917748536153915e-37421', 54, 3);
T('2.88239839811E-8', '1.00000002882398439651103026262165361e+0', 36, 5);
T('4.872597579273030979E-9', '1.000000004872597591144134583049737594772e+0', 40, 3);
T('-0.006757678445087613180', '9.9326510331773435581771e-1', 23, 4);
T('-1719061.5525618361809019383320908921878454', '1.131541164e-746579', 12, 6);
T('3.71051', '4.087464728225990240044723377214455688119502630072e+1', 49, 2);
T('-0.710995', '4.911552547738170878579930706792986093798e-1', 40, 6);
T('-6430924786.8769350318286788585173815', '3.345810365131120619165374101594810429694464421676283e-2792915149', 52, 2);
T('34642362.26867654539909580015', '5.93443858705705339e+15044986', 18, 0);
T('-7E+9', '4.755949192618e-3040061374', 13, 6);
T('-4.47019198135193978079214717754', '1.14451183902750885e-2', 18, 1);
T('51.34638954589307373157723989', '1.99275379758365308341255892760527578727823654790483676129019e+22', 60, 1);
T('-81401.3615', '6.8846384527819219975911487677597427557337305e-35353', 44, 1);
T('756198.669234325520158524481477094', '8.11467349161070913472039775323650842804795027540355532e+328412', 55, 4);
T('-9400.940934454609508553', '1.67196610124e-4083', 13, 5);
T('5.696', '2.9767431911766615488230490231563e+2', 32, 4);
T('38968.323782499938173874579040559', '5.34549292380094578902304159007522885358394e+16923', 42, 4);
T('62.9891003860774546630961822849372513516610', '2.26891756745795123507049600807686043e+27', 36, 4);
T('-4.8E+7', '7.38999104745748e-20846136', 15, 4);
T('-0.00211257', '9.9789e-1', 6, 4);
T('-0.0000050272045563902', '9.9999e-1', 5, 5);
T('-781312946.5632340188253766262', '4.6560453442132538317833940921452340405282959703223e-339319902', 50, 6);
T('-539.351152188976861', '5.79122977047606582711e-235', 21, 0);
T('-0.000003191', '9.999968090050912350846215082855477065451902402451e-1', 49, 1);
T('2491.6138389220662918906233', '1.2421e+1082', 5, 5);
T('6.5331E+5', '8.4717320950869955184340179326124820815021e+283728', 41, 6);
T('92689392.7817092', '6.547257272694308679468101443589658377028634845214991e+40254491', 53, 2);
T('-2.896540084258306486858073681654344E+6811156578945', '0e+0', 53, 0);
T('-39207182.50724003262', '9.685720935811140481048654824107565400809255139636e-17027464', 49, 2);
T('7252999.481974401492086089772266652', '4.49023040782864506582532036714073311031e+3149937', 40, 2);
T('266860.99729013895036', '1.81367015289299e+115896', 15, 4);
T('554.714299304131', '8.116321104500913004975e+240', 22, 4);
T('-5.39E-9', '9.999999946100000145260499739015302018344e-1', 40, 6);
T('-6.1956126230176979843715238', '2.038354074486265884213790326313520268133059783156e-3', 49, 3);
T('-179079.468663437447364925039698865156', '5.955761566079939707214078176734503062189331061405114979e-77774', 55, 4);
T('0.0004272552696486380060251990096888432070184565922867687789', '1.000427346556181780477698753215244914199293256647682497e+0', 55, 4);
T('-3604941.277081', '7.86644408655531682331137104e-1565607', 27, 5);
T('0.00392514874030933504732799676958623', '1.00393286222551638245758336302140689303e+0', 39, 3);
T('-8.070278020750073242509686640353603E-6533213', '1e+0', 37, 6);
T('-60.027781', '8.51e-27', 3, 3);
T('-5.151759E+4667803654705425', '0e+0', 24, 4);
T('-1.6415863E+316', '0e+0', 26, 2);
T('14444.797502185090179819521204795229610403898990', '1.9762752e+6273', 8, 0);
T('-7.9538558E+8', '4.174289266691080722771583364812366141505670477566749e-345431569', 52, 3);
T('-5.24', '5.30025683587e-3', 12, 3);
T('8770981783.8768836961', '4.0895045834438370341124833e+3809188989', 26, 1);
T('-7781095035.8787823767376187', '5.6632e-3379286638', 5, 2);
T('4280.31872095948288', '8.294711777842760220189848873553814022570332637458e+1858', 49, 1);
T('419522830.42755215461439329805041612595938252479988924364672', '1.9369550145179668054855717656498132e+182196450', 35, 6);
T('22204.72689074417274008', '2.45674917534239889126155594669739769204350979022435e+9643', 51, 3);
T('193143291.17221363238156', '4e+83881065', 1, 2);
T('-3.3269283071078E+3105804030310579', '0e+0', 37, 5);
T('-8.0492E+6', '7.18231329681123631192574e-3495724', 24, 0);
T('-8.2E-7', '9.9999918000033619990810535217173691050172889810529415773493e-1', 59, 1);
T('67538.931211623', '6.0973180748876020894953118261270483e+29331', 35, 4);
T('-2407.658244174797831950742368037560548516', '2.329754965378927665184597e-1046', 25, 6);
T('7.126663757956691E-7', '1.000000712e+0', 10, 3);
T('-8676.117277', '1.02362822745e-3768', 13, 4);
T('-44563.67436389', '1.74634654439880489827627486840970065e-19354', 36, 6);
T('-4.77838156949708135194588629542265625E+505476', '0e+0', 31, 0);
T('-1.883462276255022060068783713668189011761149256412782839814E+90148', '0e+0', 56, 6);
T('-6758.44188742150205573936972028595077986', '7.0142627304093313514490351637550786117813876056148253994e-2936', 56, 5);
T('648374386.8454786539250981171527107608073', '2.5965442555841821646e+281585418', 20, 6);
T('-18935271.6751', '9.9578395934e-8223485', 11, 0);
T('-1828.9535229', '4.9610927564232141817416706579973675e-795', 35, 0);
T('-970517.1659009', '6e-421491', 1, 0);
T('-29164.29207900217', '1.28493593415121280566442e-12666', 24, 3);
T('6698643518.220071149702566573678899151073324730343386674566', '1.58475395523360337062144184558308465480566891047377328e+2909183916', 54, 1);
T('-1.228963425393376142204523523367867E+38670263', '0e+0', 42, 0);
T('12.28462457248174674', '2.16343904820253358102399514306929165e+5', 36, 2);
T('-1406895221.617695531859022088478547953084394157514360', '4.31899059503150821494312668700741280316233831045635e-611006832', 51, 4);
T('-5464971607.2426373191', '1.64655936028692914480673449308075079881431973e-2373407013', 45, 1);
T('3917982.761376313384123284170581080', '1.96543098291186591077226844907e+1701558', 30, 6);
T('-2.67337924185113452801381547E+62', '0e+0', 35, 2);
T('-3.23925924417871900610119818564E-51571806070210', '1e+0', 52, 4);
T('-95956.28263404765534567752652673855344056495958804881', '5.19e-41674', 3, 3);
T('2.062', '7.861677452345232127891940658427123462730566099e+0', 46, 5);
T('-2.636653938950473266562426470563546906283343399', '7.160044865166421077350801345790271714163e-2', 40, 0);
T('67.0398031069', '1.303216461822694955321864e+29', 25, 1);
T('435029945.228734', '5e+188931104', 1, 2);
T('-7E-431', '1e+0', 19, 5);
T('561690400.8295265089', '4.1523032738483148535256191020203081982783134145061136572e+243939041', 57, 6);
T('6.71501831417284738990640952632075989921369685E-8954800535452', '1e+0', 16, 4);
T('951324.40298784730', '8.684e+413154', 4, 4);
T('101.8581637893332049152879', '1.723607878310329717394363029e+44', 29, 3);
T('-8.4616875278931291409525352275E-74255734837', '1e+0', 22, 6);
T('-4.48333446062045843605E+2891890077362', '0e+0', 22, 3);
T('-4733476.33934857674525911436192438770558502', '2.21616100477564906494357644077395286035437795151209665e-2055723', 54, 2);
T('-9E+8350994284697', '0e+0', 2, 2);
T('-2.59092369214850687887297928934274952E+15093499179', '0e+0', 48, 5);
T('6.94481E+6', '4.580011013258511348327640529505139178762663557127e+3016092', 49, 5);
T('-5.306593163163116266439E+32', '0e+0', 39, 6);
T('-8812510.98065065091256792468975697664659', '1.28644613902718205e-3827225', 18, 4);
T('-6.7E+29900513741', '0e+0', 28, 1);
T('0.000002514468289207001024863622086943168979951212204851901477945', '1.00000251447145048503938255996372459e+0', 36, 2);
T('-52626.9809769628976655', '2.469236e-22856', 7, 2);
T('-7.182696E+691', '0e+0', 52, 1);
T('0.912506453988875268663913120314486124504360042269', '2.49055718367631688222592171757840884345156946e+0', 45, 4);
T('-8.4230491536070E-9', '9.999999915769508818668784e-1', 25, 4);
T('3.771403590061E-29926', '1.0000000000001e+0', 14, 0);
T('-446.30408660719608455426202', '1.487982883988403390825709e-194', 25, 6);
T('618361.54116592', '1.0119278522063e+268551', 14, 0);
T('-9613.258278989752964742967465688250500721591497815', '1.035085736399780132274292916671435710997585584152744627545e-4175', 58, 2);
T('-3.599813101198099745394491250E-52863', '1e+0', 21, 6);
T('8934251869.70509916655', '8.845756812926329107811969e+3880096286', 26, 3);
T('7855419.967463209585539869194725832755166821616420', '3.50672648908711338945919e+3411565', 24, 2);
T('-93.032345940324798771195234705684685176321683166', '3.949712819836329105068e-41', 22, 0);
T('-11.35', '1.176948962493174023609e-5', 23, 4);
T('-276080277.17373478014980', '1.151136148083759924472639599e-119900141', 28, 5);
T('-9024.9373198895597966096346284177871', '3.3076720940073134958705073e-3920', 27, 6);
T('7477832507.9032', '6.013322857098335653837e+3247581394', 22, 6);
T('-87275.52487305417025633', '5.2618979682795171690116206e-37904', 26, 5);
T('-4.8535479887310024460060041733378168099389727345263378E-3126214409912517', '1e+0', 7, 6);
T('-1.508830E+9', '7.411678029552501726030879351530397448445e-655276544', 41, 1);
T('-2.8289809421082857219160789803542065437166E+89062671910696', '0e+0', 22, 4);
T('1.04849280004E-85410018295', '1e+0', 24, 1);
T('-5.68600E+204864013879', '0e+0', 58, 5);
T('-9.849150684976800', '5.279201102858537143500027599653116576517114e-5', 43, 1);
T('-7.047265544829266331642000314503945043394541857255190088', '8.6e-4', 2, 1);
T('-7661.37071783597688218395168714356213724640', '5.116505304086334166136461683364e-3328', 31, 4);
T('-2244343.1065029498995591566524191883433246173', '1.49055555235318519649688137e-974706', 28, 3);
T('-6114285103.366747598804331', '6.67679134689133733e-2655400282', 18, 2);
T('-0.00000580025971697798003818318457832024974772396564244054765', '9.999941997571044958892e-1', 22, 0);
T('-5.089247245102748788890E+7626459', '0e+0', 33, 1);
T('3207.0074216806456875151728', '6.104170542e+1392', 10, 2);
T('-80419846.22836357706354612659743327225903307', '3.52787882576328800568927309247e-34925896', 30, 4);
T('-7.98541613782832011E+6723', '0e+0', 32, 3);
T('-9.596932364405894312026643548991705122339774816698', '6.8e-5', 2, 5);
T('4.935246952949651272858021831479390226', '1.39e+2', 3, 5);
T('-531.6784214980321886974779464', '1.2445014196851604e-231', 19, 0);
T('-4.739E+1946136908872', '0e+0', 25, 5);
T('-0.01572268858755079', '9.844002676364299520864907e-1', 25, 1);
T('-579096033.9505229314113261994543', '9.188184615720464240471695850252709e-251498213', 34, 1);
T('0.00009389319853973274722619083766246456', '1.0000938976066440613502042057296e+0', 32, 4);
T('-37555.3344', '8.423722442596589600279765854984943551317911562042659e-16311', 52, 2);
T('-1.95935319094250841299718333E-9', '9.99999998040646811e-1', 18, 4);
T('8.8082297739838814733818533E-499208659', '1e+0', 23, 3);
T('-7.0515915591849E-7', '1e+0', 1, 2);
T('-0.002938308763435210899326052363477937844398106330598158693', '9.9706600384080442298699e-1', 23, 4);
T('-4687980.714965767635940561505490', '6.9858861864156761389498600852369559945e-2035965', 38, 6);
T('-118181608.73475834214480841859810569284', '2.911020776248796477233979e-51325621', 25, 1);
T('-27749.05223777560549446143398857182877847303717', '5.49205767029747647750398388611802e-12052', 33, 3);
T('-171072.90446684238722603078340853702012370010124898774', '9.584884594681422574319e-74297', 22, 1);
T('504284606.023382353403823645166', '5.066526343118473926417712611714042955313894412464e+219008021', 49, 1);
T('-45923250.0456552932187869600478411602688855582497508713', '8.205567995038854456e-19944215', 19, 6);
T('-78.5765353866969685265699193648183539711921582107046908576639', '7.4928023126342711451765e-35', 23, 5);
T('-61.98488954832959431787', '1.203107704018125105e-27', 19, 6);
T('-8847387724.5367366666884569160104766', '9.45e-3842371669', 3, 0);
T('-6.25E+3', '4.565497451354961248083150215077477303875629e-2715', 43, 3);
T('5.860E+9', '8.97543921445671647226260745544950893481e+2544965663', 39, 4);
T('7252457734.4849935833858729076273919595507202403356104488', '2.10567e+3149702374', 6, 3);
T('-4.3862970217733830473904720685818862615844', '1.2446733975475708833005974385328167538080828967597890932e-2', 56, 4);
T('-4.68934787890988807211444814851E-79789912', '1e+0', 19, 6);
T('53050.2039105320', '2.575266547064047627057929848861121028197850194380460494978e+23039', 59, 0);
T('-5.9878797445E+3760252320', '0e+0', 8, 0);
T('-9.020351799344287452628267E+619931548698281', '0e+0', 18, 2);
T('-3.408053670415183195657633495676602E+7356059680465606', '0e+0', 51, 3);
T('-5.09176714096460076E+14574387', '0e+0', 54, 5);
T('1.11637E+8', '1.1919e+48483333', 5, 5);
T('-0.00074381', '9.992564665580849103129003991e-1', 28, 6);
T('6E+9', '2.627307864980124157947705731161461284923491e+2605766891', 43, 2);
T('-2.946847002254208208778140940E+73', '0e+0', 29, 1);
T('9266.981936837000050214623147', '3.973004577e+4024', 10, 6);
T('-0.00003597602918', '9.999640246179495773726538747849433155e-1', 38, 5);
T('-429160.7559606346157904985705860675328786999238177329480', '7.109464145080662262774044985869664257213386372e-186383', 47, 4);
T('-648878.2', '6.002230722e-281805', 10, 0);
T('16.5253443376539291260', '1.5026777551646922421e+7', 20, 6);
T('5306698950.837477401048404827816985193451853343112', '2.9545564317306745907155920150679272935106790390724796662e+2304670071', 56, 4);
T('-88.6577409807824760086030795365823402237900907234', '3.136406274721600338623406478e-39', 28, 1);
T('-9.37E+4', '4.04618434380113177881778074205e-40694', 30, 0);
T('-63.257345094437457682030579895958920384250992524', '3.37042048439e-28', 12, 0);
T('-0.00000477150291930', '1e+0', 3, 5);
T('-844839.5', '7.36302199269051751169281578441834018715206033191716981747966e-366910', 60, 3);
T('-9.60490645978663911094666506641660930135564363069196E-4522558128', '1e+0', 60, 4);
T('-9358.925393136069132854850960921', '2.9535560489873714567138990832905195490519253782320583102309e-4065', 59, 3);
T('-865261.219611027358842', '6.71302173120865859435636879e-375779', 27, 3);
T('603567872.879120488508439678', '4.42064247873697079062e+262126196', 22, 4);
T('-0.471857991528865341609540775858032230406225060206423011', '6.2384209749021740782416505778e-1', 29, 0);
T('-8.0E+5', '2.59703258366139809054380138862e-347436', 30, 4);
T('-60.302335669148993629', '6.471849e-27', 8, 4);
T('62623796.5468058153449566517692997772537684633672450182478478', '1.8884682276005656212170815041697442265326639581524604352e+27197169', 56, 3);
T('-48.553924855981485096634227653075627806863881900625', '8.1902726662034e-22', 14, 6);
T('-3587.1381583700904849385031812103', '1.335647929594325224571385891e-1558', 28, 5);
T('-9.69198538848682887121627322264761026844E-67075626', '1e+0', 12, 5);
T('-50.7760561277', '8.87644386517672310743901058e-23', 27, 1);
T('-833.8172', '7.547292e-363', 7, 0);
T('0.000007878726144730576281142460329153106627045103316048112349', '1.0000079e+0', 8, 4);
T('-4E+8748594574', '0e+0', 50, 5);
T('6E+3', '5.846438956502114727850463535700123362780731971728e+2605', 49, 3);
T('-4.8821013132742502966450440E+3614608', '0e+0', 13, 1);
T('8.044E+9', '2.69003358149422826966036199693345465325421330326351698e+3493464812', 54, 2);
T('71179.39573699949056115908959847127731381113858917558448', '6.59e+30912', 3, 0);
T('-1.37E+9', '6.202188995867221908509949e-594983441', 25, 1);
T('-5.69620613352909376544642278439908175721060560741319E+8688769', '0e+0', 14, 5);
T('-1471672480.0738587102408', '5.43312669474655741e-639139238', 18, 3);
T('590730.3321031024414299257979388800', '8.385428356536552e+256550', 16, 0);
T('-60.89557919718450', '3.57590508114398588678207895721413537571e-27', 39, 6);
T('-2761507.0', '5.5996746785704194931311e-1199308', 23, 4);
T('198214.59589706259035750663520644', '3.20059540370481547485293577625754483845229753e+86083', 45, 2);
T('3.98404381174717436228401637500065496134160352', '5.373e+1', 4, 1);
T('-2.7933892295985002533148877132521390363228176450757E-6849654', '1e+0', 55, 6);
T('-4.607470472360977321677009341368730', '9.9770235725838785333721011723268189899453e-3', 41, 0);
T('4E+8', '5.771659887496014191829519e+173717792', 25, 4);
T('26989323.9384597741276273360182517003085710709957957514448', '2.862677468062e+11721314', 13, 6);
T('1982.67804963846670829039696512311674728663365524161003570', '1.1644915693429422090661483073823e+861', 32, 5);
T('2.312712520453006155305277051215E-966684305342', '1e+0', 32, 3);
T('-0.079241668813823896297184805509227188136', '9.2381663979417533e-1', 17, 0);
T('-7.688568386264063474826911053471204738263444451802620E-324922020138799', '9.99999999999999999999999999999999999999e-1', 39, 1);
T('-7.305094225925E-98705932828', '1e+0', 15, 5);
T('-27193.09105963791865212391852529008352836876', '1.55e-11810', 4, 3);
T('4E+5', '6.20527882613588673626e+173717', 21, 4);
T('-1.995919734E-8', '9.9999998004e-1', 12, 3);
T('-4083312085.13', '3.46082571227260141989249138182703943854064440051514225e-1773359907', 54, 1);
T('3.95084818023937700604675550481579437722396407984433395E-8200841523936978', '1.000000000000000000000000000000000000001e+0', 40, 0);
T('-90559.2451560', '4.164313582093632454540322279075574117497371193329543e-39330', 52, 5);
T('92092.2767439047124009947106002375774419044032914', '1.4710105415708809121746920993811e+39995', 32, 4);
T('72.04903391663415974995136499534181873911433084830820302664', '1.9520810991406029504505878089e+31', 29, 6);
T('34.69052508722296764076631217454', '1.1638677107734747705843067730591703481767725570233718484813e+15', 59, 3);
T('0.000741671391959064355247599949976506540964380747774691231', '1.001e+0', 4, 0);
T('841348.304475', '8.43319513400894367304409974588146e+365392', 33, 2);
T('123822.65013725', '3.116658689758209388503610924383e+53775', 31, 0);
T('-5960667203.802488752442867386', '8.45e-2588684876', 3, 1);
T('4E+3', '1.5063559700505249009759190747414992458097e+1737', 41, 2);
T('-0.00000783514268781890972746', '9.99992164888006831393806301832147045916749165e-1', 45, 2);
T('6.9E-9', '1.000000006900000023805000054751500094446337630336e+0', 49, 0);
T('305155.72764993972564517', '2.8095679521281084951012803831304299857163496186e+132527', 47, 2);
T('2034841.534415453716037408621096503934082445550167', '2.8180206903608061507101910350075349e+883720', 36, 3);
T('2545141627.98', '4.94279962988124992988887881698092e+1105340964', 33, 2);
T('0.003456485541607408664012431739377', '1.0034624660763157833821887059e+0', 29, 5);
T('0.00048178897456179800519303750034', '1.0004819e+0', 8, 4);
T('-1.4811873578429339516146825701788853245875879906979042410E+72605', '0e+0', 4, 1);
T('-3.0714157907710673653E-8107005448411807', '1e+0', 59, 6);
T('0.0003129138765143464883823736210681842794827503440653514696', '1.0003129628391683022163e+0', 23, 0);
T('-9.3327409050543206953670E+131180977', '0e+0', 6, 0);
T('-1E-7', '9.99999900000005e-1', 19, 2);
T('-0.3445495279070169584', '7.0853945884135634925014671658652560447191937821e-1', 47, 1);
T('2.25051849596497241967352487', '9.49265646465912365377289454355252e+0', 33, 2);
T('-67.963750482920796905913629710401961', '3.0459179188004299035995603e-30', 26, 4);
T('0.337320146', '1.401187576537793e+0', 16, 4);
T('-2.2713E+9', '1.79120017852431842298947e-986413057', 24, 4);
T('-6.64870032493454828741112E-6776', '9.99999999999999999999999999999999999999999e-1', 42, 3);
T('7021850.11260080215885061268655272015672825', '5.71023860575880222265485e+3049550', 24, 4);
T('-2.0515545E+662214112126232', '0e+0', 47, 3);
T('2957797835.8932577253481756853632731222315814045', '5.173945340113688270718638e+1284555278', 25, 6);
T('-35.4384823', '4.06689247392565826039961568289935115764584923877809e-16', 51, 0);
T('933.826978527752257585969585221682736305117', '3.5966967873001430219224114539e+405', 29, 4);
T('-5.629837408193', '3.589158847715504981e-3', 19, 5);
T('0.098887749540990386230695224887553630245651731897792', '1.10394237456542819e+0', 18, 3);
T('-6178.578818796317272266065847381165952721343853821647', '4.75678e-2684', 6, 4);
T('-0.00235659', '9.976461845782716291e-1', 19, 0);
T('-391393.3630624422845', '1.052369918014655240761093524557205117100010284177e-169980', 49, 5);
T('-0.4869312266345366794989117009036180748664436275333', '6.14509293363631602887407244384521502505994676972e-1', 48, 2);
T('589.007821555', '6.35106707e+255', 9, 1);
T('6.9E+6', '8.41651763267734118568759237292604145293295813726609653847322e+2996631', 60, 2);
T('-5.013342E+7688736', '0e+0', 40, 2);
T('-99203.98160158821556981821877062655348086', '1.81220614417096157740427353081667296927920648015826e-43084', 51, 0);
T('-0.012169447574280893468602026868779312386533694638', '9.879043e-1', 7, 5);
T('-336.2955189849', '8.886113e-147', 7, 0);
T('-0.0511195005030005301788909364635510380021762', '9.5016512e-1', 8, 6);
T('-1.165566116907531216714416836918486143313411185177518641754', '3.11746127314187147654404e-1', 24, 0);
T('-8.11E+7', '3.29341e-35221283', 6, 1);
T('6.7E-8', '1.0000000670000022445000501271675062967195843e+0', 44, 3);
T('-936.4918528162902030566588492010221267608', '1.9353342145915577342e-407', 21, 3);
T('6944779', '1.5766583069682807158185490274259561064055723e+3016079', 44, 4);
T('1.5565847195195926700694715755E-2036687', '1e+0', 51, 6);
T('-190562626.1162471451160352499905', '1e-82760297', 1, 6);
T('-5E+1', '1.92874984796391778301734e-22', 24, 1);
T('5717.80873119769611139073', '1.63222692405910843260564015e+2483', 27, 6);
T('4826561.868945951907995629717907045526779', '1.5354931135171e+2096149', 14, 3);
T('-5008845855.2856', '2.21559342680400786e-2175314116', 18, 0);
T('-1.20827044448276358E+8178688297534794', '0e+0', 18, 0);
T('20614806.1194031494', '3.492707172941925579964900276501e+8952896', 31, 0);
T('-5.91126459112161796319224642922215757742522049407E-64612884', '1e+0', 5, 5);
T('8.5052595389354880301833994128050929444686896463910E-1426620730709', '1e+0', 6, 4);
T('5.69367424103244983564962068038157191864666910236983', '2.969828048600207499273983417195805345305540798642082508e+2', 55, 5);
T('789391360.59555761873990640645908909860673298488856', '9.3057361824431439172040625633393796044026224352373e+342828311', 50, 3);
T('7.863438787771571071335613542611450957858008225457283E-3629884487', '1e+0', 17, 5);
T('7.7746276218545896715411897618069920827', '2.3794570772848399465881307293917698818154272277095636175e+3', 56, 1);
T('529234708.3605546004223022298100', '2.969379040006493e+229843713', 17, 6);
T('-9.4226846E+9321323138', '0e+0', 13, 2);
T('-391747.113534650200186050404342978105602790292760', '2.46e-170134', 3, 5);
T('-8.1325881821414760241953252309577296544283', '2.9380679040846155362110181018808794406319680017541e-4', 50, 2);
T('-83299.0041880', '5.036549605690286414151859066643158778019627221306e-36177', 49, 4);
T('-74442429.480917608255860428160266', '4.539055860043039e-32329937', 16, 6);
T('-78209.5483006', '1.0586e-33966', 5, 3);
T('1371674414.4782798006474442513325367511', '1.4e+595710629', 2, 3);
T('0.18', '1.1972173631218101648768239736004794798688224554646251713e+0', 57, 6);
T('-2.59968935154212E+640214', '0e+0', 52, 4);
T('-21931.088850397678155410801650980642806094692701180', '2.812743581e-9525', 10, 3);
T('1.06800773102405E-8', '1.0000000106800773672725258793924583128971640347e+0', 47, 3);
T('73.186845', '6.090359536580918670465514922962424848022134024e+31', 46, 4);
T('86513.751209187670', '2.78457488e+37572', 9, 6);
T('-4.4248744070865983825689279887432768346742E+2320751954', '0e+0', 59, 5);
T('-47771.82438970366542437504706798117298', '9.1259293129171539627304039278272e-20748', 32, 5);
T('87620.80589239557089341997186454400068405670609', '1.7081e+38053', 5, 2);
T('-0.0005255055', '9.994747e-1', 7, 2);
T('-6.171622E+3192918596', '0e+0', 11, 2);
T('-74231.5799564343750256169689119415859716043415211329112845', '4.309649596367124306e-32239', 19, 5);
T('1214586007.2', '5.294967442073563946946e+527488000', 22, 4);
T('11819.315346', '1.1572698593143973580600227470387584732318087962884284085e+5133', 56, 6);
T('3.359012E+7', '5.787194214907765811784571024538182849685958293767517123e+14588003', 55, 0);
T('8.5617961670211748089749295450727155148', '5.228063218806710296762681e+3', 26, 5);
T('8811.8741490751854844607187', '8.8780619114358641401102283e+3826', 26, 6);
T('52160610.212513659', '1.54170430724264983039790913572445593420539875754401e+22653065', 51, 5);
T('-9.3532702531262197619807634384413419286795', '8.6681484e-5', 8, 3);
T('-0.36145995164469064639321602456568627444990521225958364208', '6.9665849554378670792390678384991701954077e-1', 41, 3);
T('6.7365387886080957143036410304081694350511E-850853', '1e+0', 32, 1);
T('-4.12045065E+9017133661', '0e+0', 5, 6);
T('-1.9583E-772666713078175', '1e+0', 1, 2);
T('-95316324.450979907665643940391257489874110', '1.8015214057492e-41395354', 14, 2);
T('-9.60626078852727745956443154E-66505783139', '1e+0', 10, 4);
T('5.624914202E-3292151007465', '1e+0', 32, 1);
T('0.00095632', '1.0009567774197728e+0', 18, 4);
T('572.250874833453739', '3.3527193771992483060917268990517797994590446367282e+248', 50, 1);
T('7.061118724709411E-8', '1.0000000706111897e+0', 17, 5);
T('-3.47342149715648741231749076186152333298225E-7', '9.999996526579106076287590398262e-1', 31, 3);
T('0.000003233216257806967940204807227510000289843462516243918458', '1.0000032332e+0', 11, 1);
T('57757010.086062973164715', '5.91027391788e+25083550', 12, 1);
T('-23873009.1260', '7.415701281249413990635434257516836728566958573e-10367917', 46, 5);
T('605.0770657001636023391929015529833078', '6.048264284301187978321475653528383322610238e+262', 43, 3);
T('-6.19079', '2.04820802962117862947601102928920975e-3', 36, 5);
T('283316004.403238205573741', '2.22435320495564731565809774681597795937722266368e+123042577', 48, 3);
T('-407774536.4087', '9.485165966160525479712039149429210834615195546681288e-177094232', 52, 4);
T('7.4646E+9', '4.1211041725630244805175433086287961628331772430159e+3241834589', 52, 2);
T('-936724046.0023013524956116', '5.6900057170766157035788756e-406814085', 26, 2);
T('-5.4711980517E+609015923073', '0e+0', 14, 4);
T('-9.075152424E-9', '9.99999990924847617179195634847378765808e-1', 39, 4);
T('-511798242.732886492435249127253106888981401637', '2.1544001e-222271153', 8, 0);
T('-7.57651', '5.12346e-4', 6, 3);
T('-8.743393066562572849006726953E-7', '9.9999912566107557824289628094487200725231047007075128030919e-1', 59, 2);
T('-9255827.04458', '2.44955966e-4019755', 9, 3);
T('40216642.51588', '8.4201997586589672583424602415454114664730709783089914467842e+17465865', 59, 6);
T('0.0000018353509099015847382000862768838612931823929620557963693257', '1.00000183535259415909637751549891279996e+0', 39, 6);
T('0.0000397391631073482165324026618632283670', '1.000039739952718349911570036708835430112516828147828189581e+0', 58, 0);
T('-8.42271438550089937699047920E+878408157', '0e+0', 46, 3);
T('-1.718977747558816965149259925978126281768954542470854535814E+661320705271', '0e+0', 3, 0);
T('815941574.959696224225621673679816232641937219342', '3.6344992741237470277099161527389162559e+354358923', 38, 1);
T('-18532215.720776624649552', '9.44117433576543205198312171177100127989596e-8048440', 42, 4);
T('-0.000675295449079737950484815015243664218609899340258043751247', '9.993249325115755507335216575676760854708009000360799e-1', 52, 4);
T('-7993439211.464893455705253', '1.0757621750625665818743411103007433e-3471506541', 35, 1);
T('-4.347985E-8', '9.999999565201509452486643114932381e-1', 34, 2);
T('-2.417252360011198402000401E+643', '0e+0', 32, 1);
T('-0.3541043447128080262722112509998', '7.01801734234309135112196072e-1', 27, 0);
T('6.18E-8', '1e+0', 4, 4);
T('0.0000820490395255055006816269', '1.00008205240564001055421670409599157335247125054165035568627e+0', 60, 6);
T('-2.522202158301361178E+12405070195', '0e+0', 28, 3);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,253 @@
var count = (function floor(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, n) {
assert(String(expected), new Decimal(String(value)).floor(n).toString());
}
log('\n Testing floor...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
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('-834103872107533086', '-834103872107533086');
T('-1501493189970436', '-1501493189970435.74866616700317');
T('70591', '70591.2244675522123484658978887');
T('4446128540401735117', '4446128540401735117.435836700611264749985822486641350492901');
T('-597273', '-597273');
T('729117', '729117');
T('4803729546823170064608098091', '4803729546823170064608098091');
T('-6581532150677269472830', '-6581532150677269472829.38194951340848938896000325718062365494');
T('2949426983040959', '2949426983040959.8911208825380208568451907');
T('25166', '25166.125888418871654557352055849116604612621573251770362');
T('4560569286495', '4560569286495.98300685103599898554605198');
T('13', '13.763105480576616251068323541559825687');
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.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('39181479479778357', '39181479479778357');
T('0', '0.00000000000000000087964700066672916651');
T('115083055948552475', '115083055948552475');
T('9105942082143427451223', '9105942082143427451223');
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);
Decimal.toExpNeg = -100;
Decimal.toExpPos = 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
assertException(function () {new Decimal('0.6').floor(0)}, "floor(0)");
assertException(function () {new Decimal('1.6').floor(0)}, "floor(0)");
T('0.6', '0.66', 1);
T('1', '1.66', 1);
T('0.6666', '0.66666', 4);
T('1.666', '1.66666', 4);
T('0.6', '0.6', 1);
T('1', '1.6', 1);
T('0.66', '0.666', 2);
T('1.6', '1.66', 2);
T('0.66666', '0.666666', 5);
T('1.6666', '1.66666', 5);
assert('1', new Decimal('1.9999999999').floor().toString());
T('-1', '-1.0', 1);
T('-2', '-1.00001', 1);
T('-1.1', '-1.010203', 2);
T('-3', '-2.999', 3);
T('-0.0002', '-0.000123', 1);
T('-0.000123', '-0.000123', 4);
T('0.010203', '0.010203', 5);
T('0.010203', '0.01020301', 6);
T('-9.999', '-9.999', 6);
T('-9.99991', '-9.999900000001', 6);
T('0', '1e-9000000000000000');
T('-1', '-1e-9000000000000000');
T('0', '-9.9e-9000000000000001');
T('9.999999e+9000000000000000', '9.999999e+9000000000000000');
T('-9.999999e+9000000000000000', '-9.999999e+9000000000000000');
T('Infinity', '1E9000000000000001');
T('-Infinity', '-1e+9000000000000001');
T('5.5879983320336874473209567979e+287894365', '5.5879983320336874473209567979e+287894365');
T('-5.5879983320336874473209567979e+287894365', '-5.5879983320336874473209567979e+287894365');
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,374 @@
var count = (function others(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 isFinite, isInteger, isNaN, isNegative, isZero...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: true
});
n = new Decimal(1);
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(true, n.isInteger());
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 Decimal(1, 10), 26));
assert(true, n.equals(new Decimal(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 Decimal('-0.1');
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(false, n.isZero());
assert(false, n.isInt());
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 Decimal(Infinity);
assert(false, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(false, n.isInteger());
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 Decimal('-Infinity');
assert(false, n.isFinite());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(false, n.isZero());
assert(false, n.isInt());
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 Decimal('0.0000000');
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(true, n.isZero());
assert(true, n.isInteger());
assert(true, n.eq(-0));
assert(true, n.gt(-0.000001));
assert(false, n.gte(0.1));
assert(true, n.lt(0.0001));
assert(true, n.lte(-0));
assert(n.toString(), n.valueOf());
n = new Decimal(-0);
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(true, n.isZero());
assert(true, n.isInt());
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 Decimal('NaN');
assert(false, n.isFinite());
assert(true, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(false, n.isInteger());
assert(false, n.eq(NaN));
assert(false, n.eq(Infinity));
assert(false, n.gt(0));
assert(false, n.gte(0));
assert(false, n.lt(1));
assert(false, n.lte(-0));
assert(false, n.lte(-1));
assert(n.toString(), n.valueOf());
Decimal.errors = false;
n = new Decimal('hiya');
assert(false, n.isFinite());
assert(true, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(false, n.isInteger());
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());
Decimal.errors = true;
n = new Decimal('-1.234e+2');
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(true, n.isNeg());
assert(false, n.isZero());
assert(false, n.isInt());
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 Decimal('5e-200');
assert(true, n.isFinite());
assert(false, n.isNaN());
assert(false, n.isNegative());
assert(false, n.isZero());
assert(false, n.isInteger());
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 Decimal('1');
assert(true, n.equals(n));
assert(true, n.equals(n.toString()));
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));
Decimal.errors = false;
assert(false, new Decimal(NaN).equals(0));
assert(false, new Decimal(null).equals(0));
assert(false, new Decimal(undefined).equals(0));
assert(false, new Decimal(Infinity).equals(0));
assert(false, new Decimal([]).equals(0));
assert(false, new Decimal([]).equals(0));
assert(false, new Decimal({}).equals(0));
assert(false, new Decimal('').equals(0));
assert(false, new Decimal(' ').equals(0));
assert(false, new Decimal('\t').equals(0));
assert(false, new Decimal('gerg').equals(0));
assert(false, new Decimal(new Date).equals(0));
assert(false, new Decimal(new RegExp).equals(0));
assert(false, new Decimal(0.1).equals(0));
assert(false, new Decimal(1e9 + 1).equals(1e9));
assert(false, new Decimal(1e9 - 1).equals(1e9));
assert(true, new Decimal(1e9 + 1).equals(1e9 + 1));
assert(true, new Decimal(1).equals(1));
assert(false, new Decimal(1).equals(-1));
assert(false, new Decimal(NaN).equals('efffe'));
assert(false, new Decimal('b').greaterThan('a'));
assert(false, new Decimal('a').lessThan('b', 10));
assert(true, new Decimal('a', 16).lessThanOrEqualTo('ff', 16));
assert(true, new Decimal('b', 16).greaterThanOrEqualTo(9, 16));
Decimal.errors = true;
assert(true, new Decimal(10).greaterThan(10, 2));
assert(true, new Decimal(10).greaterThan(10, 3));
assert(true, new Decimal(10).greaterThan(10, 4));
assert(true, new Decimal(10).greaterThan(10, 5));
assert(true, new Decimal(10).greaterThan(10, 6));
assert(true, new Decimal(10).greaterThan(10, 7));
assert(true, new Decimal(10).greaterThan(10, 8));
assert(true, new Decimal(10).greaterThan(10, 9));
assert(false, new Decimal(10).greaterThan(10, 10));
assert(false, new Decimal(10).greaterThan(10, 11));
assert(false, new Decimal(10).greaterThan(10, 12));
assert(false, new Decimal(10).greaterThan(10, 13));
assert(true, new Decimal(10).lessThan(10, 11));
assert(true, new Decimal(10).lessThan(10, 12));
assert(true, new Decimal(10).lessThan(10, 13));
assert(true, new Decimal(10).lessThan(10, 14));
assert(true, new Decimal(10).lessThan(10, 15));
assert(true, new Decimal(10).lessThan(10, 16));
assert(true, new Decimal(10).lessThan(10, 17));
assert(true, new Decimal(10).lessThan(10, 18));
assert(true, new Decimal(10).lessThan(10, 19));
assert(true, new Decimal(10).lessThan(10, 20));
assert(true, new Decimal(10).lessThan(10, 21));
assert(true, new Decimal(10).lessThan(10, 22));
assert(true, new Decimal(10).lessThan(10, 34));
assert(true, new Decimal(10).lessThan(10, 35));
assert(true, new Decimal(10).lessThan(10, 36));
assert(false, new Decimal(NaN).lessThan(NaN));
assert(false, new Decimal(Infinity).lessThan(-Infinity));
assert(false, new Decimal(Infinity).lessThan(Infinity));
assert(true, new Decimal(Infinity, 10).lessThanOrEqualTo(Infinity, 2));
assert(false, new Decimal(NaN).greaterThanOrEqualTo(NaN));
assert(true, new Decimal(Infinity).greaterThanOrEqualTo(Infinity));
assert(true, new Decimal(Infinity).greaterThanOrEqualTo(-Infinity));
assert(false, new Decimal(NaN).greaterThanOrEqualTo(-Infinity));
assert(true, new Decimal(-Infinity).greaterThanOrEqualTo(-Infinity));
assert(false, new Decimal(2, 10).greaterThan(10, 2));
assert(false, new Decimal(10, 2).lessThan(2, 10));
assert(true, new Decimal(255).lessThanOrEqualTo('ff', 16));
assert(true, new Decimal('a', 16).greaterThanOrEqualTo(9, 16));
assert(false, new Decimal(0).lessThanOrEqualTo('NaN'));
assert(false, new Decimal(0).greaterThanOrEqualTo(NaN));
assert(false, new Decimal(NaN, 2).lessThanOrEqualTo('NaN', 36));
assert(false, new Decimal(NaN, 36).greaterThanOrEqualTo(NaN, 2));
assert(false, new Decimal(0).lessThanOrEqualTo(-Infinity));
assert(true, new Decimal(0).greaterThanOrEqualTo(-Infinity));
assert(true, new Decimal(0).lessThanOrEqualTo('Infinity', 36));
assert(false, new Decimal(0).greaterThanOrEqualTo('Infinity', 36));
assert(false, new Decimal(10).lessThanOrEqualTo(20, 4));
assert(true, new Decimal(10).lessThanOrEqualTo(20, 5));
assert(false, new Decimal(10).greaterThanOrEqualTo(20, 6));
assert(false, new Decimal(1.23001e-2).lessThan(1.23e-2));
assert(true, new Decimal(1.23e-2).lt(1.23001e-2));
assert(false, new Decimal(1e-2).lessThan(9.999999e-3));
assert(true, new Decimal(9.999999e-3).lt(1e-2));
assert(false, new Decimal(1.23001e+2).lessThan(1.23e+2));
assert(true, new Decimal(1.23e+2).lt(1.23001e+2));
assert(true, new Decimal(9.999999e+2).lessThan(1e+3));
assert(false, new Decimal(1e+3).lt(9.9999999e+2));
assert(false, new Decimal(1.23001e-2).lessThanOrEqualTo(1.23e-2));
assert(true, new Decimal(1.23e-2).lte(1.23001e-2));
assert(false, new Decimal(1e-2).lessThanOrEqualTo(9.999999e-3));
assert(true, new Decimal(9.999999e-3).lte(1e-2));
assert(false, new Decimal(1.23001e+2).lessThanOrEqualTo(1.23e+2));
assert(true, new Decimal(1.23e+2).lte(1.23001e+2));
assert(true, new Decimal(9.999999e+2).lessThanOrEqualTo(1e+3));
assert(false, new Decimal(1e+3).lte(9.9999999e+2));
assert(true, new Decimal(1.23001e-2).greaterThan(1.23e-2));
assert(false, new Decimal(1.23e-2).gt(1.23001e-2));
assert(true, new Decimal(1e-2).greaterThan(9.999999e-3));
assert(false, new Decimal(9.999999e-3).gt(1e-2));
assert(true, new Decimal(1.23001e+2).greaterThan(1.23e+2));
assert(false, new Decimal(1.23e+2).gt(1.23001e+2));
assert(false, new Decimal(9.999999e+2).greaterThan(1e+3));
assert(true, new Decimal(1e+3).gt(9.9999999e+2));
assert(true, new Decimal(1.23001e-2).greaterThanOrEqualTo(1.23e-2));
assert(false, new Decimal(1.23e-2).gte(1.23001e-2));
assert(true, new Decimal(1e-2).greaterThanOrEqualTo(9.999999e-3));
assert(false, new Decimal(9.999999e-3).gte(1e-2));
assert(true, new Decimal(1.23001e+2).greaterThanOrEqualTo(1.23e+2));
assert(false, new Decimal(1.23e+2).gte(1.23001e+2));
assert(false, new Decimal(9.999999e+2).greaterThanOrEqualTo(1e+3));
assert(true, new Decimal(1e+3).gte(9.9999999e+2));
assert(false, new Decimal('1.0000000000000000000001').isInteger());
assert(false, new Decimal('0.999999999999999999999').isInteger());
assert(true, new Decimal('4e4').isInteger());
assert(true, new Decimal('-4e4').isInteger());
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,620 @@
var count = (function ln(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
function T(arg, expected, pr, rm) {
total++;
Decimal.config({ rounding: rm, precision: pr });
var actual = new Decimal(arg).ln().toString();
//if ( total % 100 == 0 ) log( total);
if ( expected !== actual ) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
error(' precision: ' + pr );
error(' RM: ' + ['UP', 'DOWN', 'CEIL', 'FLOOR', 'HALF_UP', 'HALF_DOWN', 'HALF_EVEN'][rm]);
log('');
//process.exit();
} else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
log('\n Testing ln...');
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
('0', '-Infinity', 40, 4);
T('0', String(Math.log(0)), 40, 4);
T('-0', String('-Infinity'), 40, 4);
T('-0', String(Math.log(-0)), 40, 4);
T('1', '0', 40, 4);
T('1', String(Math.log(1)), 40, 4);
T('-Infinity', 'NaN', 40, 4);
T('-Infinity', String(Math.log(-Infinity)), 40, 4);
T('Infinity', 'Infinity', 40, 4);
T('Infinity', String(Math.log(Infinity)), 40, 4);
T('NaN', 'NaN', 40, 4);
T('NaN', String(Math.log(NaN)), 40, 4);
T('2.7182818284590452353602874713526624977572', '1', 39, 4);
T('91247532.65728', '18.3290865106890306', 19, 1);
T('727579403.9', '20.40523369730819818291393006', 28, 3);
T('419065154.52076499608', '19.8535369658470908', 19, 2);
T('130749452.494110812', '18.68879347348', 13, 6);
T('1185619573.5511384009507900359', '20.89353132177529891789', 22, 0);
T('530465273.44', '20.089265053819159', 17, 4);
T('93521824.19043496087', '18.353705380823595707150211318', 29, 3);
T('93587439.79738005953', '18.354406742245', 14, 0);
T('913009834.17782778193371741', '20.63225720978034314683755252', 29, 4);
T('96363417.9729392663575231665', '18.3836372059508935007674191717', 30, 0);
T('210401674.5643546532430157', '19.1645289977522148145584372801492541489626022147443118341', 57, 3);
T('952417276.8651321118737418', '20.67451381275802954644121920485653995422386303532469652920020456933991073071', 76, 3);
T('98184005.146079977', '18.4023538796720926822257754284842101571428491604633542324254915295389687459768262219847229005105726462911110014778700105379820806407462050611141071631637279703966033404550534991584986282367905158391520156932087898507160577425969648962582513228749121815449650331654608429478028655815089', 285, 6);
T('142322563.253900033190831713543268828109981967888490291406527346535501984011990242137300064766425179727442507442591862989037644368590904104621357145575632132596634560836335843482822061685451360570260600926717066081883739008412790434377893984866700040372917562269733068809727985812968781985268403920729907489962116060023323078359102582924017315196797171078484331048743611378544575282691634826207', '18.77360661165643483904346', 25, 4);
T('371400293.53826507744653292410472631048281764405036030167939649508120465472946573115185753424640793913438158589233749086894500415028950753895660006551599374916249772634013307822672548085573611750200419176163913242813545244921337312493040312898991903677477383181667469789752847529551033664230833747974881304800992388176411266053764', '19.732790997238693', 17, 5);
T('308061625.88823978041274039804998186206865791141980152103127270513511076834989316028752984249313112128128502539231626511285494530858340408577571344790765131399576822101736125139886541136712372342853393859483419254236049454263746814598084065516321822244266672902276617353573868701264411419113453133557772924904083715036037838173144284202571542029689590647862395', '19.5', 3, 4);
T('56166207.244290436722984261495400654889250285124533321022981475832539124544579218170536475258779537248807554699941937121725987852537935501915601362', '17.8438258394282509999', 21, 6);
T('222624724.707607328646707303867967259139519139629423079746317622391060720425657380049896682204826804719116517331792375328854607227578421004813898208914187979742668659057386237112777304292626154363413399007128375956303978756008642562104282496678212208286912567720592497594790267585324990906417857716073248926170009724869749739256517', '19.2209980629988594846457575', 27, 0);
T('185258598.8193913934519764713459928878217005284578212999298749640634191497175066526732902777761314076480735321777689520905932035413871290869941575745986362030629539', '19.03726323844184819241728391212796712905475895', 46, 3);
T('269693209.738329262863103619932258583418154544819938948520850885129975757878155942909813913575593873613967345697983513739799036745044974770565058447912595936725318596664619637466457786273308379783363276858754429871221986504763671381169376146393662591214420480616860804709987497567541966840009610585879458456647716651843692095645431144825029791181857768800342074145503590855886070320931830102002860548331131946643428330049680453526744262227', '19.4128', 6, 2);
T('1023342793.682203550119853590855855440825349592189658219400017324862237829261909743084375742003621225707754353154890001299178609037775929182416', '20.7', 3, 4);
T('288066409.930742086163569035868595871340060157483817829526835857178700227646660208478255306458767689905569779533532613990984463726169225', '19.4787016015557225466209307245195728148', 39, 6);
T('659962551.7196736389816108624246917556391933488125636501841767846136469655007635589597690345289565290187266991221823977105182413305954975153418768184526414022291854836356848438340284898272452919407497723633962181806929526702888572755311195630908175133297801595820610915241491322973994939537556926297001075794108221345170572608247217166782978965314275924298103649904183225053518681061802488451326', '20.307693651556304624603', 23, 2);
T('1507364652.7412807014310450849045388639397320237966928257974087635919752464931336652652563316012320514301796477028177198948086347984093073988211028197354698778354347658908468312563297806615829593697914663744507730778747959075016883455899218807867027301117084501104764662133718266594886462034333606057118803676760138265831276687149773555531764176520964444746495235029665718222485165667080758798726878577774041717453053559075165574861878572784439577325279859720699815', '21.133628699942067740343303809380556857137955185', 47, 5);
T('390145000.967298821818782016684792033527978825236257109725032636684195216173865101534596314015627154955417417356051726409514707961291776124601310897', '19.782029025340505793950028597475307602798983116', 47, 1);
T('1582186416.193367134722504736788921341001732540902935815137028669849087377143230724513115136185091885228053584573993361147951779854091136019178181014965525402328169438038737972227467851264', '21.18207353512', 13, 1);
T('444181511.379330635761040379043896319', '19.9117438462696047845568005370964420406847915', 45, 2);
T('1649165442.81508159186866091659911601847915727898761380479217148722967003628844958192423020437941929274541019164440472673454567347131337845196944956123772899539516241995922964069898844748283940385593209556832209762517653421012964293705687275161487307996022854435621786593342404292930985767687391343569565159759022658057195057590383081972675845225107300959105018192214115690180632353307', '21.223535204669576956240210909820794512745', 41, 5);
T('956193088.33977562292786906645507064275401232361020165960269744050571700135755870903976551991970971401541090373022939626590186869869098847675469870075789885973042670437758904496341260362989490245294442892663605116104481315514350394492341667402397008571518074733491886421982724176798753763402802355543297381889941871793636978236549161242963426659386692353226535780947411516134695241409391848436453976510684', '20.678470425872231784432536313273269750899620287', 47, 6);
T('524656579.6561082202986522788989992058097028959478133491616251386650273315481201712733337497961653741466850177948', '20.07825447252854998238544895', 28, 1);
T('412184042.8896878204667114461794718285421610397268782502943123737616921059160330553262782457035088179494074564563410048773731594742762676033110116212190491442443442166045598309788282584460671280467345157657971668722189192696185094311918310776057781011454221034130478455744396828404806478740586228712397995429199362271635020780002483852222338852479130612370279841990621710882872848128725669571603659740938524254161291050199148884609411958653228755273145468', '19.83698051361329059', 19, 5);
T('54177615.4161615199898039376707204324649188748836298320352749128620609118474310429998270745885186642610341190928928278585051565238331611651463560104044550438095405103019768593446391808685915870067181972775276870790595322163624212767962894314519491376965719216779872096909267426650844863008221945010966830813924747797605343830807190598639058151734866383440974952571052161557282681608575287009214045591019', '17.807779', 8, 0);
T('202208538.0186996731425487962109425863325508616918249176043925148428750848485730129706779656165064759679330957399949664528408543769938770452288279928848232018815279096218064756460984277961961770343996043873166572208624824439463192886927974622714849727874835303030139509530094904609301858682577824229369378223655885781140501472159022060380707281531318049222808388638845419183185', '19.124810089270938003831849629', 29, 4);
T('419077532.2448607619101987942607612824719743129742324423040412531483957695007192401517535342220366141599584852033167948744863351374575147495928944631030285526934314990168106650729902570735596692781194661598925404746581114061618262181809902436423306258562179673075380899236033671', '19.85356650192559415566417', 25, 3);
T('146708483.32674399300686866605976073019721421720619119889933263331964327217855614280622971093931911986466782717253122036096979367739887439449073138969919020714899901453823470883487750734885842377270384469297548135028684586032301609167142204835412029755367943305773471371240556395996807312138338709086180854612022228560209117316657640810924077420852085218504347155816788970471703339876', '18.803958069162751518238485267', 29, 5);
// 0.00000000000000000000000000000000000000000000000000012300000000007559999999999999999999999999999999999999243549999999070119999999714232000000000000000000000062028900000114375240000070298928000014402707200950...
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.000000000000000000000000000000000000000000000000000123', 3, 1);
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.000000000000000000000000000000000000000000000000000123', 3, 1);
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.0000000000000000000000000000000000000000000000000001230000000000756', 16, 0);
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.0000000000000000000000000000000000000000000000000001230000000000755', 16, 1);
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.00000000000000000000000000000000000000000000000000012300000000007559', 17, 1);
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.0000000000000000000000000000000000000000000000000001230000000000755999999999999999999999999999999999999924354999999907011999999971423201', 85, 0);
T('1.0000000000000000000000000000000000000000000000000001230000000000756', '0.00000000000000000000000000000000000000000000000000012300000000007559999999999999999999999999999999999999243549999999070119999999714232', 83, 1);
// 0.000000001229999999999549999690409...
T('1.000000001230000000756', '0.00000000122', 3, 1);
T('1.000000001230000000756', '0.00000000122999', 6, 1);
T('1.000000001230000000756', '0.00000000122999999999954', 15, 1);
T('0.9999999', '-0.0000001000000050000003333333583333353333335000000142857155357144', 58, 3);
T('0.999', '-0.001000500333583533500142983', 25, 0);
T('0.99', '-0.0100503358536', 12, 3);
T('1.0000000000001', '0.00000000000009999999999999501', 16, 2);
T('1.0000000000001', '0.0000000000000999999999999951', 15, 2);
T('1.0000000000001', '0.000000000000099999999999996', 14, 2);
T('1.00000000000001', '0.00000000000000999999999999996', 15, 2);
T('1.000000000000000000000000000000000000001', '0.0000000000000000000000000000000000000009999999999999999999999999999999999999995000001', 46, 0);
T('8.1', '2.09186', 6, 1);
T('39.6', '3.67883', 7, 2);
T('13.83', '2.62684015', 9, 4);
T('46.7', '4', 1, 0);
T('47.9', '4', 1, 4);
T('98.9', '4.59410924', 9, 4);
T('28.1', '3.33576957', 9, 3);
T('19.4', '2.9652731', 8, 0);
T('1.8', '0.587786665', 9, 4);
T('63.8', '4', 1, 4);
T('3.5', '1.25276296', 9, 3);
T('72.91', '5', 1, 2);
T('7.54', '2.020223', 7, 0);
T('61.1', '4.11251186', 9, 3);
T('64.3', '4.16', 3, 4);
T('70.4', '4.26', 3, 0);
T('40.34', '3.6973435', 8, 1);
T('97.56', '4.580468', 7, 0);
T('4.2', '1.4350845', 8, 1);
T('14.23', '2.65535', 6, 1);
T('21.41', '3.06', 3, 1);
T('86.5', '4.46014', 6, 3);
T('53.5', '3.97968', 6, 4);
T('41.2', '4', 1, 4);
T('22.67', '3.121', 4, 1);
T('39.1', '3.666122466', 10, 1);
T('20.8', '3.035', 4, 0);
T('27.72', '3.3221541743', 11, 3);
T('484260633.26', '19.9981', 6, 1);
T('739084458.57', '20.420922760027607325270794371574372', 35, 3);
T('173897238.6257338023989', '18.9739751001054747115892', 24, 0);
T('234294644.588885865140275679', '19.2720900461484484624992', 24, 6);
T('663446355.03930603', '20.312', 5, 3);
T('236924096.650141980105861288', '19.2832503', 9, 1);
T('383519031.802423', '19.7648998041', 12, 3);
T('495413774.3180056262693', '20.02090387906982718762754628426', 31, 0);
T('103272854.9147823146420226558', '18.4528851204168398068299228814439335', 36, 2);
T('1255876919.801289301817086', '20.9510999', 9, 4);
T('892565379.904099781', '20.6096103237295763729453899449191', 33, 5);
T('714436577.20394836', '20.38700479', 10, 2);
T('114209899', '18.5535', 6, 6);
T('11138070.731145', '16.225879593546584', 17, 1);
T('173982352.98970322915408', '18.9744644324360810729339336092249432', 36, 0);
T('601898865.418395208648', '20.2155999915160485142287883', 27, 2);
T('1737398240.940989286501485', '21.3', 3, 5);
T('1223195313.271302839406', '20.93', 4, 2);
T('483960664.70757792519406292', '19.9975141901128827175535702', 27, 0);
T('254561643.88559655966887725', '19.35505359', 10, 0);
T('230901371.26208883297662', '19.25750121307751', 16, 2);
T('39049637.3708272077470901', '17.480344148', 11, 5);
T('605727.08861135233', '13.314184814787811646051719561794', 32, 5);
T('110166953.414692391364862', '18.51750753144102983720945609400314449', 37, 3);
T('341161100.758980208051', '19.6478653599282687781757344218', 31, 4);
T('316912316.269705411968295', '19.57413568875', 13, 1);
T('1471705773.129049604979506', '21.1096879548887928212', 21, 2);
T('43608215.24072301429834', '17.6', 4, 0);
T('692035632.3', '20.3551480040192941281921918635691', 33, 4);
T('437966495.9954174972446009', '19.9', 3, 2);
T('1021072161.39012', '20.74411905080098544439092', 25, 0);
T('420919239.137', '19.85795154221623', 16, 2);
T('1478634317.69367498567837', '21.114384740403810652547', 23, 3);
T('7030.0000000004', '8.8579419848047674873993819813049734644306', 41, 3);
T('14302.00090090005', '9.5681547295995328150820246661661705098', 38, 1);
T('31131.999969929999979999', '10.34599150711339159800792', 25, 2);
T('11604.0000000000070005080090000000805009', '9.35910514524129523926613596795448321965442856295', 48, 3);
T('31917.99991999999899997969', '10.37092539045270895006814258635431', 34, 2);
T('26753.94999', '10.194438', 8, 2);
T('29279.05000800090000700009000000000080004005030000097', '10.2846275224669583306543625537', 30, 3);
T('11553.00407000007000030000092', '9.3547007747724112152725332649758224586144889', 44, 4);
T('26807.0000000200007', '10.1964183264243228688799088559564488641428510584', 48, 2);
T('3714.999299999999899999999959999496999998995979949999999969399979', '8.2201337687265389341123277272836362405282053685', 47, 2);
T('11275.000001000060000080002000020000001000000000000005', '9.330343164459576214650017260944374', 34, 1);
T('18404.00107000000000000700701009003008000000000000700203', '9.820323369414893', 16, 0);
T('11735.00000000200002', '9.37033110828529432', 18, 3);
T('29285.9', '10.28486145051', 13, 2);
T('24143.9999999999999599999999', '10.09179118100763013383', 22, 0);
T('1189.0000030020000000000000000080000006000030900907', '7.08086789921559259321173351103264209976', 39, 3);
T('27341.0000008', '10.2161426860830683625276502597036387295831', 42, 1);
T('21469.99999999999969', '9.9744118908728266982', 20, 2);
T('3243.000000900007000000305000060209000000004000000900600000600013', '8.0842542', 8, 0);
T('16240.999999', '9.695294188113030278102040381421186919123', 40, 1);
T('2258.999199', '7.72267716188626709813978452604048821542674214', 45, 3);
T('14805.999994993999999999994994999999999799999999999299999999999', '9.602787782664937484827890675974506248220680541057', 49, 1);
T('6159.00400302', '8.725670355633251921000813056', 29, 0);
T('22763.99999999996999998992999959999939899999', '10.03293561972301', 16, 4);
T('12087.000090000000900500000000020500000000002', '9.3998857813', 11, 4);
T('24056.00008007005', '10.0881397279968507', 18, 0);
T('1273.9', '7.14983834011574117903670501641161393434448327659', 48, 0);
T('31641.0006006003000000000000000000050001', '10.36220904592643417978456213185992074668712', 43, 4);
T('28152.060004000000000000000007', '10.2453758104285329372599741260889658', 36, 3);
T('27680.00040003001010000500400000070000000000000050002', '10.228465424183556996128', 23, 2);
T('31218.00002030000000100090000050704010007079', '10.348750131168624384483033071', 29, 0);
T('11417.9', '9.342937578384608', 16, 4);
//T('32707.999999999999', '10.3953749752818678489320219880615537660291155044917', 51, 1);
//T('118.99919995999999993999997999969996929', '4.779116770063719665537354046547378965557836797331856', 52, 3);
//T('17003.000000009000000000000000008', '9.741145078058015120919966501835143176156861419343740556541117', 61, 1);
//T('5417.97999999995929', '8.5974783312391794404618615144733099701627808172306624190104', 59, 2);
//T('1910.00100800020000040080000500070000000000009000000103', '7.5548590487893321092493645504085904544269955602005918211488331009847021601', 74, 2);
//T('32557.06000009000500000040040906075', '10.39074952120212178676079851539819418947762372961119669968067255284802897919359', 79, 2);
//T('8040.999199919699999999999999999999999999', '8.99230863304804460753592307494251846465228698521103876361634564070723067896557346434919675579', 93, 1);
//T('7319.00000005000100000004000000000009', '8.89822898560805878904761165587090389264537190352296428956966832703610074883381141507', 84, 2);
//T('20310.9999999', '9.918917890186562244968424278603316340336947919638737985462507627', 64, 0);
//T('1865.929999999999999999999', '7.53151486730600202121187231421215331113719071231590668559688561585178308997617359', 81, 4);
//T('23803.99999991999699999999995999999999999992999', '10.077608912761381778736458393923595013034857506079245555323031047010217918', 74, 4);
//T('12355.919797999999999999999998999999995999999993999391959999799', '9.42189056308182825449261540594475019345782742905017092725206071556756117892238167813104527', 90, 2);
//T('32660.99999999999969999939299', '10.39393698454928970646418244077107009755598815038162339657646292060461', 70, 0);
//T('17709.99919997999999999969995994999999999499999', '9.7818846856035298129365954355795348738519296338403079799232', 59, 4);
//T('19337.0040500007010070200000009000000200009003', '9.86977584749364284732220940142679710834986678876757626888837356337', 66, 0);
//T('26462.00030700107000000000000000000002004060030003000060020051', '10.18346503220393850606641364105600718151424217086782526011175902576661812', 73, 1);
//T('28848.0000000000400000006', '10.269795945443099894915200707425485584129640345896850256138694782745392498654', 77, 0);
//T('9392.98999999999999999969299499', '9.1477189453713573857882056319571056740464593896051932528811008963', 65, 2);
//T('25178.000070000070600079', '10.1337258791064123151940564913830339390827751148270764918185106990262', 69, 4);
//T('18242.000000000800503', '9.81148190674014761473860402979206369203499493293928030034434523449386957123678821928204789542103', 96, 0);
//T('9561.09008050010000010050000006000080000000009000030000700700000039', '9.16545702470198712386460633659768976266096103334844651537188472210976621230639', 78, 4);
//T('11028.9895996999997929999999999999999399999999999919799299', '9.30828250330996376298611011103650620092856368264931544', 54, 1);
//T('28844.00090006', '10.269657309241059585300999912511959701942019848752529073893042016649458375814747', 80, 4);
//T('26242.99999891993999999999999999999999999919', '10.17515456575006921215429566578414104445757463514895213750953681749838728525348821013874861037', 94, 1);
//T('10030.02', '9.2133378749719393252570289887303808575821698458159358337454066577217184443028458304776267', 90, 1);
//T('158.00003', '5.0625952229003664991540681459232750446463749674703150729247615588767906575595913608636517363665', 95, 2);
//T('10937.0004000050004005000000000400080000070000202050500409', '9.29990685190878279434878530457971600539108168557165608709161247804986560209112533325843474269', 93, 4);
//T('24938.00004005', '10.124148025162514314437447283009386892615340936238579182010186864370198470438495916166304724938', 95, 0);
//T('20814.9999999999992939999999996999999999999195999', '9.943429159629075778328751497673715914946468296455215', 52, 1);
//T('31836.9', '10.368381273409305496912425292471083297044456118366175647491226108496591954145', 77, 0);
//T('18013.99', '9.798903957219741450054167466144013259668415139470381146149306872023157736620280933673199060891031101', 100, 3);
T('0.9999999999999999999199499999969999979699999999999999', '-0.00000000000000000008005000000300000203320400125024025016', 37, 4);
T('0.000010000000000000900406000400000060000021', '-11.51292546497013837', 19, 2);
T('0.999999999999939994989999999', '-0.000000000000060005010000002800300612550182023047506056', 41, 3);
T('0.979999999999999999', '-0.02020270731751944942845346428', 28, 1);
T('0.009009005050040300000400008', '-4.7095306407579573919326957858245838', 35, 4);
T('0.060080080020000000060000000000000080900000000000600000008087', '-2.81207693963633246203151', 24, 4);
T('0.999997999999399997999993999949', '-0.000002000002600005866683246750786841565741132', 40, 4);
T('0.999999999999999999929929999997999979999999929799', '-0.00000000000000000007007000000200002000245497265114014', 34, 4);
T('0.08000009', '-2.5257275193088882518096775704454984610695', 41, 3);
T('0.00090400000000000000000004060600070700000809', '-7.0086811975720976072740759519732589', 35, 4);
T('0.000704006', '-7.25872367911527720999907560001613988913676912731866147366599498415', 66, 1);
T('0.08', '-2.52572864430825543979', 21, 0);
T('0.9999999929999199999499999999999999799999499', '-0.0000000070000800245505601178872580008623040894857280221937339', 53, 0);
T('0.99499998999694996999999999999999999397999299999', '-0.0050125518769', 11, 3);
T('0.0000000000020000007000005000002', '-26.93787358536841414877187370746409029977817', 43, 0);
T('0.009000002000002', '-4.71053048', 10, 0);
T('0.03000004', '-3.5065565639875372314061705613342488', 36, 2);
//T('0.997993999999999991999599999999999299999992999999699999', '-0.0020080147127934705720207831518473000385779980977470623', 53, 2);
//T('0.1', '-2.302585092994045684017991454684364207601101488628772976034', 58, 3);
//T('0.07031', '-2.6548412427710670875991961912705608964273058315882958906477709', 62, 3);
//T('0.0004', '-7.8240460108562921172375015758211036942534056857945813958919515849', 65, 3);
//T('0.99999919999999', '-0.00000080000033000017866677551673740271454970000600464904056264501690000535763355', 74, 1);
//T('0.9999959999929991999399999999959999', '-0.00000400001500084939673409258793327262602303164413557781745578952196590341854025998711387811614682', 93, 2);
//T('0.00000000000002000000000000001000000000006050001000400302', '-31.54304412135669376683464824109804683813977121890114984832930172', 64, 3);
//T('0.000000004002000300001', '-19.33647152582210368342944015985184842325594103405320629705965390835550192578795', 79, 1);
//T('0.999999', '-0.00000100000050000033333358333353333350000014285726785725396835396834487742821075513383', 81, 3);
//T('0.9999999999994999999999', '-0.000000000000500000000100125000000050041666671691682291671679172917003756252604669169792808239659', 84, 4);
//T('0.9997994999919999959999929999999999999999999999929', '-0.00020052011081372911068085773896011669967700702863612628789084640641308301386054257702857', 86, 3);
//T('0.000000000002060000000200900300008', '-26.9083151330295340785911897845861042304210111766941991354101811695274344547681167', 81, 2);
//T('0.9949', '-0.005113049386823021094256519096874037227386760004460981181242634002334168834982178887', 82, 0);
//T('0.9993999994999299999499', '-0.00060018057240263786837522687966806289003406196252219014240123702227012525913313385968', 83, 0);
//T('0.99599', '-0.0040180616085841388623141765986877584137526338579018515175937371657638575417674718', 80, 1);
T('0.1754385964912280701754385965', '-1.74046617484051', 15, 3);
T('6.0', '1.791759469228055', 16, 6);
T('0.5', '-0.6931471805599453', 17, 2);
T('2.5', '0.91', 2, 1);
T('0.142857', '-1.94591114905582', 15, 3);
T('0.4545454545454545454', '-0.788457360364270169', 18, 2);
T('0.05', '-2.995732273553990993', 19, 2);
T('9.0', '2.1972245773362194', 17, 6);
T('2.0', '0.693147180559945', 15, 1);
T('0.02132196162046908315', '-3.84801767545223368', 18, 4);
T('0.1063829787234042553191', '-2.2407096893', 11, 0);
T('2.7', '0.9932518', 7, 0);
T('0.013440860215', '-4.3094559418430461815', 20, 1);
T('0.0107526881720430107526881', '-4.53259', 6, 2);
T('0.03125', '-3', 1, 5);
T('2.3', '0.8329', 4, 4);
T('0.015151515', '-4.18965475203', 12, 5);
T('0.01162790697674418', '-4.45434729626', 12, 0);
T('0.01584786053882725', '-4.1447207695471679983', 20, 3);
T('9.3', '2.2300144001', 11, 3);
T('36.0', '3.5835', 5, 3);
T('0.0111111111', '-4.4998096713302', 14, 2);
T('2.8', '1.1', 2, 2);
T('9.0', '2.197224577336219', 16, 3);
T('0.011363636363636363636', '-4.4', 2, 2);
T('70.0', '4.248495242', 11, 1);
T('0.0111111111111111', '-4.49980967033', 12, 5);
T('4.0', '1.39', 3, 5);
T('0.01117318', '-4.49423901528089', 15, 5);
T('0.2', '-1.60943791243410038', 18, 3);
T('0.2941176470588235294117', '-1.2237754316221157056', 20, 5);
T('25.0', '3.218875824868200749', 19, 4);
T('0.19230769230769230769230', '-1.64865862558738168', 18, 3);
T('35.0', '3.5553480614', 11, 3);
T('50.0', '3.9120230054281460586', 20, 5);
T('0.0241545893719806763285024', '-3.7233', 5, 4);
T('12.0', '2.484906', 7, 3);
T('0.077519379844', '-2.55722731138003', 15, 0);
T('78.9', '4', 1, 6);
T('4.9', '1.589235205116580927', 19, 2);
T('59.8', '4.091005660956586', 16, 1);
T('4.2', '1.43509', 6, 0);
T('0.02', '-3.9121', 5, 3);
T('60.0', '4.09', 3, 1);
T('0.7692307', '-0.26236435', 8, 2);
T('0.333333333333', '-1.09861228866911', 15, 0);
T('0.02732240437158469945', '-3.600048240407', 13, 5);
T('0.061728395061728395', '-2.8', 2, 6);
T('8.0', '2.07944154', 9, 5);
T('0.9999999999999999999999999999999999999568192301488826794261698690972956411635111284787367786816502083882422798578731605252106199479075698', '-0.00000000000000000000000000000000000004318076985111732057383013090270435884', 37, 4);
T('0.9999999999999999999999979550666058305047704469654544926170385722676726565280928302935213393351515069436413391635857924053031503612857234287', '-0.000000000000000000000002044933394169495', 16, 6);
T('0.9999999999999999999999999999788589934323601088222420429829335393675583983311669404940044418555472559469792115593688854910667629732945617', '-0.000000000000000000000000000021141006567639891177757', 23, 2);
T('0.99999965612996150232225742078449327047019615530457466722741143133687180033806758021000178033650121765045177844535360974813202360649705716806472085515573024723452129710679277030691649', '-0.00000034387009762099298460124920225891418549479847', 44, 3);
T('0.999999999999999999998', '-0.000000000000000000002', 11, 6);
T('0.99998389456495199790866464051967145510973599943414379845553913640458143099808775839406749813252', '-0.0000161055647419136538238914419840240365', 36, 5);
T('1.000000000000000000000000000000000000000002453877989156637807977474490521127775312951564217698150', '0.0000000000000000000000000000000000000000024539', 5, 4);
T('0.999999987593466883036919655717507752311798436584262710410080485802440651098', '-0.00000001240653', 7, 6);
T('1.000000018472078439367595548243230561734', '0.0000000184720782687587567141685374276721136', 36, 0);
T('1.000000000000000000000000000027061294139028140296788935076920940602313183007831066627748504596064337387546517866314036676735728406098988897643792775080246506595767189394976464369', '0.0000000000000000000000000000271', 3, 6);
T('0.999999999999999999999999999999999999999999999999983236514849608313776995668242152423498923869153102324092773269164486380023512206', '-0.0000000000000000000000000000000000000000000000000167634851503916862230043317578', 30, 2);
T('0.999999999999999999998364', '-0.000000000000000000001636', 12, 4);
T('0.999999999984247763351546132381201803224221320759305237486792312341695697664625337191197409538174918606370093200173235377160974530349186640210056578324041384176737202852579773243', '-0.0000000000157522366485779340985139462', 27, 6);
T('0.9999999999999999999990018683160077458539750633020995640413381403082761992348270405950390259594627171842', '-0.0000000000000000000009981317', 7, 4);
T('0.99999999999999999999999999999999999999999999999999985408483944', '-0.00000000000000000000000000000000000000000000000000014591516056', 35, 1);
T('0.999999999999999999999999999999999999999999999999998739619976', '-0.000000000000000000000000000000000000000000000000001260380024', 19, 6);
T('0.99999999999999999999999999999999999999999999999999999885639999798325100337440101041086693875558962971018414706077286569119145472180293030705985903425546926770196944598420458571451206946321039210', '-0.0000000000000000000000000000000000000000000000000000011436000020167489966255989895891330612444103702898', 50, 5);
T('0.9999999999999999999999999999998813849879156043674936830517787361054747787', '-0.0000000000000000000000000000001186', 4, 2);
T('1.0000000000000000000278495935577735173108449580311901557454985107031530689779032404701969152386509968231412912032547047938976884258008764161145204', '0.000000000000000000027849', 5, 1);
T('0.9999999999999999973362461433229285135656310591384423930035289356669163226763087894358613606844049018612982044184276721128495686590536237237362306901212', '-0.0000000000000000026637538566770714899821612453425437643031829', 44, 5);
T('1.00000000000000176253868933517211924999595559448630464030179930682524750778432581467161581396555777249054042674040627129810092955303337', '0.000000000000001762538689335170566', 20, 5);
T('0.99999999999999999999999999999999999977092768577305435532481001390241851854279230037455', '-0.000000000000000000000000000000000000229072314226945644675189986097581481', 36, 1);
T('0.9999999999999999999999999999999999999999999999999999999872655993173067727213258266707420877839338907224927740881477058093177568467325181347117970284259875332114167', '-0.0000000000000000000000000000000000000000000000000000000127344006826932272786742', 24, 3);
T('1.0000000172264280662442594957709154039786849716698889540202736142143930380', '0.00000001722642791786934923900676', 25, 5);
T('0.999999999999999999999999999999999982912873108922', '-0.000000000000000000000000000000000017087126891078', 29, 2);
T('0.999999999999999999999999999999999999999999993901016148293422192196736265601661935467416309801727317670352425687933', '-0.0000000000000000000000000000000000000000000060989838517065778078032637343983381', 35, 5);
T('1.0000000000000000000000000000000000001557068218834187197100492745906330662942472387805706361042981050161586903484636128434617775053436339425448812194544548', '0.0000000000000000000000000000000000001557068218834187197100492745906330663', 37, 6);
T('0.9999999999999999999999999999965', '-0.000000000000000000000000000003500000000000000000000000000006125', 37, 4);
T('0.999999999978069784575542971695341560698127887742654234264366033657806', '-0.00000000002193021542469749548', 19, 6);
T('0.99999999999999999999999999999999999999971989402139646726487926603258362083338', '-0.00000000000000000000000000000000000000028010597861', 11, 3);
T('1.0000000005777313213100622689185785411683162890830022421832393625555641832484284367817582206653835891277275299383003063423401888577943921722016789943432463695865333', '0.00000000057773132114317552917152047', 26, 0);
T('0.99998899817496551713109615150897242336013399949226209047495781001932', '-0.000011001885556', 11, 3);
T('0.9999999999999999999999999999999999999998297812400933250983600309185363087152186898130964880717734025466693634260269779753896445207544565324993821252294277099318291490267724329103905', '-0.00000000000000000000000000000000000000017021875990667490163996908', 26, 2);
T('0.999999999999999999999999999999867678505517799638290521749019978249164551148555611278304293867128540415736157410807909474981350886279390744210330912921984627066838448347590465998102019224', '-0.0000000000000000000000000000001323', 4, 6);
T('0.99999999999999955124573963968202720343790876222338286616005694319199910050972066877767645901567386160990300', '-0.0000000000000004487542', 7, 2);
T('1.00000000000000000000000000000000000000000000000000000000238653373610066251324626982217917546085298331873741456053912434675', '0.0000000000000000000000000000000000000000000000000000000023865337361006625132462698221791754608529833187', 47, 6);
T('0.9999861381597997249299307707821689337357639252598918981802356169251231384862641946832270120025664317350590928784923055179837234141982333351243328116077696716052298729080148160342', '-0.000013861936276469802', 18, 5);
T('0.999518302013578741663390652958008318798483548326838687601953768440697860', '-0.00048181404016638611452172080975', 30, 2);
T('0.999999999999999999999999999999999999999999999999999998330036520393109006599069774962', '-0.000000000000000000000000000000000000000000000000000001669963479606891', 18, 0);
T('0.9999999999971982592566014030229274322557335630334721819051248984500648246070196539508012557622985639254125086208121666523259793307451588484063477678399192077493910841989290', '-0.00000000000280174074340252185266918493667', 30, 6);
T('1.0000000000000000000000000000000000000000000000000003081468179941393977604635738549120099277215766896592811135855391834253391376095954064189345149319503595848525394170943997567283', '0.0000000000000000000000000000000000000000000000000003081468179941393977604635738549120099', 37, 3);
T('1.0101564097626380683093087282120826613421424331759509214909151214101003', '0.0101051800145446340394781491861117815898', 39, 6);
T('0.99999999999999999999999999999999999999999999999999998835768423821199588003439629108184316187951135202946432288978839496371393350180031770629223550075209192125418982248995945098956877584132', '-0.00000000000000000000000000000000000000000000000000001164231576178800411996', 22, 1);
T('0.999999999999999999999999999999999999999999999999999999999976872096656109063431181886276194814782001823830665873550337102544082509981820955995454425929992234626018878531564551440745722576230', '-0.00000000000000000000000000000000000000000000000000000000002312790334389093657', 19, 5);
T('0.9999999967066363395314220', '-0.00000000329336366589170011195437', 24, 6);
T('1.0857744658E-87', '-200.242609564754818345602', 24, 6);
T('7967796600342935039987851875126979686690856098804803834653251050081030306760096147743650654823921573015034335799167324649191446374757438.0484311242', '312.924395547087248674854', 24, 2);
T('4.959906063275914201262895287E-84', '-191.8157610097980062', 19, 3);
T('247605260094390353104779047655089617126976010142339438487265438023612656.077017582415972838691597824259541', '164.390207201496998614488673041664777028805542', 45, 0);
T('7.397668035008368', '2', 1, 3);
T('1.0643E-106', '-244.011702551303980943176356044', 30, 0);
T('2.350797564113792872976049891678503E-39', '-89', 2, 5);
T('89.249409735932840957', '5', 1, 0);
Decimal.toExpNeg = Decimal.toExpPos = 0;
T('3.22623980772186395511829472880667363767934689738221E+295688495330', '6.808479215178688102694343822133e+11', 31, 6);
T('3.1424008119820360904816828115594380261542633787339288E+6142101067398', '1.4142710357454596074562853825e+13', 29, 0);
T('8.799993E-79577', '-1.832306391942611440981400905118e+5', 32, 0);
T('8.70504056438959496505198875861603616462926E-5971', '-1.374657168803434206833683423555e+4', 31, 4);
T('8.4006029856E+923125420044', '2.1e+12', 2, 3);
T('4.0119839E-3299350', '-7.59703273728404749704426251310976420299891015285939e+6', 51, 2);
T('4.3302768368838848441860607605878081415720594735E+76594', '1.7636566824426052100565028315589397992162e+5', 41, 3);
T('3.8E+329784205242', '7.59356194896453019208845913197638776266462015689e+11', 48, 6);
T('7.6732416747937E+1102', '2.53948651164891795785685349144456466914229134475e+3', 48, 2);
T('2.077820490683659388975846E+723625853', '1.666210102754220135345042493516555e+9', 34, 4);
T('6.688785E-28910', '-6.65658346062145642467325909920069259e+4', 36, 6);
T('6.0136041193424216912E-17927305397954', '-4.1279146166878774234420729153e+13', 29, 3);
T('5.096332862894596814711832511046074722E+745', '1.71705441551516514163775766e+3', 27, 5);
T('5.84975137363E+67993', '1.565614346271e+5', 13, 6);
T('86581147739152189809997746256.485303', '6.6630879609165666865732779356483110831e+1', 39, 1);
T('2.12911330891919120203E+120504404889', '2.774716463382859039792244911807807628997e+11', 40, 2);
T('7.73433077472591367533265625623113999102E+390676254432750', '8.9956531964360115679915101731401388487e+14', 38, 6);
T('6.6826213753466680887906226588379005611546E-372991246306821', '-8.58844083563354531569986979442855776105e+14', 39, 5);
T('6.3492829903214E+3226', '7.42998785189041059280107543537699949138759874551e+3', 48, 0);
T('5.6620362147525246713E+777935299', '1.79126222452504931719151086e+9', 27, 0);
T('3.534154532190555885356307279594067464756994468E+36066880', '8.3047061501279186616689782347665205e+7', 35, 5);
T('3.5985126E+813569', '1.87331313204266617163386909806087492179897e+6', 42, 4);
T('8.02230502097885864396312997120584356127409109053488632E+57250', '1.3182507879969879935820551962408658e+5', 35, 3);
T('3.2733347380805773227156921973744955625117401773271E+7057864470', '1.625133351818013021763445401573927815324e+10', 40, 3);
T('3.200965011955166876210847170951991936E+25194197', '5.801178360560763736986182698175e+7', 31, 0);
T('2.49662549037205161930152513676222984332E-1769526964968889', '-4.074486411188359782e+15', 19, 1);
T('8.933353606087814264271069533725820479127E+94', '2.1863279060963e+2', 14, 2);
T('7.8520496399200949742657682831082508285588236E+751160063', '1.729609965577042813e+9', 20, 6);
T('9.8629670476255586848298885792269963362202371766864992350515E+76670756', '1.76540942122970827049200662319103105281075e+8', 42, 2);
T('7.164E+232', '5.36168810058817064037155119131349345287989327560924493423e+2', 57, 2);
T('7.0140848964616709789085128982324775586720562136938322979723E+94920694282961', '2.18562975672593082614e+14', 21, 0);
T('5.15295798111342379029337279689740749964293074731042E+75391', '1.73595832316829153955358568211169000080658e+5', 42, 3);
T('4.75511906567739510224E+9281276469', '2.1370928843035034699971447557867150369194e+10', 41, 1);
T('9.3428582919353239756E+9473', '2.1814623198164992616236995269818e+4', 32, 2);
T('8.69428902381899286125995853877646262336481547649342271017E+28073656389526', '6.464198270836177218138049860623405271087114955052778e+13', 52, 1);
T('3.736323028448724390151054937514728816501552616248E-859672555164790', '-1.979469210378545532338977821722936e+15', 34, 0);
T('8.3704021992314838607708728021923440173295401079057777619E+51053', '1.175560014545608380866313681e+5', 28, 0);
T('6.328946425890222657711855468334E+28226', '6.4994611968630829105921275070197989840133161484e+4', 47, 1);
T('581028.112757643064563527683530', '1.327255e+1', 7, 4);
T('5.044E+675213', '1.554737006595206671115965015e+6', 28, 2);
T('8.419E-4010970724', '-9.235601395387443688559191477601e+9', 31, 1);
T('51.2111719483', '3.9359577104e+0', 11, 2);
T('8.81634594656560180086916089974763812544168318286235E-824049757446', '-1.897444687e+12', 10, 4);
T('6.2212997114E-553559942', '-1.27461886869986969345097622349731651e+9', 36, 3);
T('235519025969854529810574120108993578243.19971', '8.8354855047659717507839540458e+1', 29, 3);
T('7.0258964578196427071536597563115415415640043575157590', '1.9e+0', 2, 3);
T('9.738596641858094986444163000772706367196726E+109229400188311', '2.52e+14', 3, 0);
T('8.62703833E+5568507422742', '1.28219621818345766335259463697135358656004154175e+13', 48, 0);
T('8.41305546301539271737600098357065745E-7295979', '-1.67996103544128833514984735034663e+7', 33, 3);
T('2.5232060242873444092576213384933104665517329499810802952E+8132082', '1.872481171374e+7', 13, 2);
T('7.9297195306E+65', '1.5173864871148797849494244247043518353031307868144564e+2', 53, 0);
T('3.64689986228734945266932E+62', '1.44054153219522787090894392411068439321378481560180842e+2', 54, 5);
T('1.334192043174385742450630E-39646400', '-9.1289209342554e+7', 14, 0);
T('2.612654672780E+2075312996908189', '4.7785847699775949720482e+15', 23, 4);
T('2578000917.79692', '2.16702800974745614276078088977272042e+1', 36, 6);
T('6.596856211693040993166106964362605852614690053358144E-8062494978', '-1.85646e+10', 6, 3);
T('6.0879876921111929476500485212617470990636329749748587985E-601', '-1.382047323290527848037209499935e+3', 31, 2);
T('3.286699439E+4569470654914505', '1.052159501287987952020793970337e+16', 31, 0);
T('3.637336824738188102903230332461981310841753899084935587E+10761051833', '2.477823753689330253840044863e+10', 28, 2);
T('3.7477430030903749357328391677904495853650E+20869', '4.8053969459485685179695549117734336870515492158e+4', 47, 2);
T('3.140337150756E-13712400984', '-3.1573970093770953376660919898558265466406669093e+10', 47, 2);
T('8.48368791870432056292625630300375084950237347894278E+624032870', '2e+9', 1, 0);
T('6.5815151328134220328E+98443649460178', '2.2667487974693907959622819142544911252715e+14', 41, 5);
T('1.7723561424140845E+247846099271', '5.7068673353869932302832431846669628468118839468307384e+11', 53, 1);
T('3.0949198435280859777489812648334758766940462500408883433646E+2469192456080', '5.68552574110429262534321058697983662070785392e+12', 45, 3);
T('0.85025805182099765686920489225574772214389', '-1.6221538519436441661125978316259087269126272e-1', 44, 4);
T('4.432834164971387041E-4507057882525783', '-1e+16', 2, 1);
T('3.988922913035675507988353278783407292371E+4694273500', '1.08089641849205055e+10', 18, 3);
T('3.01186469E+2545169058', '5.860468333203e+9', 13, 5);
T('9.0748866591646251314532E+47614', '1.096374921287092159e+5', 19, 2);
T('5.6180796113670596347965219927087524242601615E+3880377312075', '8.93489895397792489522883676797722624255e+12', 39, 1);
T('8.098147787316401427624109754110153170688558350457541922717E+8910511', '2.05172118911948342992282908397e+7', 30, 4);
T('5.42868111005864502392394132989497156E+59059832747', '1.359902905e+11', 10, 4);
T('4.70991012341588450130232666320921407597912267207E+65217922', '1.5e+8', 2, 3);
T('7.6016818135485428149331576079477334360182454470810066E+628508014', '1.44719318589e+9', 12, 4);
T('8.76577418121734880922387712030769537853138823619109E+32845', '7.5630579e+4', 8, 2);
T('3.989639481915478229949501547E-3562148605', '-9e+9', 1, 0);
T('7.50095976711871808229778395340891745932E+459172412', '1.05728355300035123967283065534499540845423548025e+9', 48, 3);
T('1.094234101086547061145E+8105185598', '1.8662879534e+10', 11, 6);
T('8.6184097550403752866225958864653E-99458373', '-2.29011364889340897937584119444696367e+8', 36, 1);
T('8.370E+4643496155876', '1.0692045027897357766979173674e+13', 29, 2);
T('8.8260530736377112408404700113658970187344553009119498E+69', '1.6105607934074696962533009034085e+2', 32, 5);
T('7.21733459581750946992541376472150E+771894752', '1.7773533512920215e+9', 17, 1);
T('8.0398697796858068264510296618162080456174991956226525E-45122871', '-1.03899248033280440664832913861293e+8', 33, 3);
T('3.85595703190443742440250277361605E+6091482618322', '1.40261570711819248808711059594479942105082367007e+13', 48, 2);
T('7.357095166801105623865E+549536691', '1.265354994745540324309072336890594e+9', 34, 5);
T('1.34533963650515436161701665448464441752127512E+350235747270701', '8.0644761e+14', 8, 4);
T('6.4170057575167730015652576742667741692190869016E+8059951144', '1.8558723356293656512085e+10', 23, 3);
T('2.4077049295833173373548E-25994301660937', '-5.98540915073e+13', 12, 6);
T('4.535541075E+20', '4.8e+1', 2, 5);
T('7.29846078607878771302050492452384424889888683E-537191033751', '-1.236928066403126e+12', 16, 1);
T('2.634898074241585E+90138333023', '2.0755118193e+11', 11, 2);
T('5.46374939035500947103431106687153167480402538E-73753665680', '-1.698240911467364203540944369371346431880400463389e+11', 49, 6);
T('2.94299515946637E+607707720', '1.3992987380488273006987151692498736952760425e+9', 44, 4);
T('3.668100638398885156015068016729087120382965349467E+84070728', '1.935800063496311111975e+8', 22, 1);
T('4.4E+2003110597803675', '4.6123326021e+15', 11, 5);
T('1.91685802862500097138466392461E+49834', '1.1474767e+5', 8, 3);
T('7.8060858E-167062888423895', '-3.8467651647738609186703184862365050751052e+14', 41, 1);
T('1.978E+5', '1.219501169817074879173281038e+1', 28, 0);
T('5.77970666253418116761098030625E+223072047', '5.13642371840220060515235912414184521974662502e+8', 47, 1);
T('5.47649676344748751812140943259036448E-6697621', '-1.5421840572658253455977679095638082e+7', 35, 2);
T('5.89272783085181716889488732225953E-80979', '-1.8645926452654519628853278905466928e+5', 35, 0);
T('3.9142246447271235587364475518772E+6792548012', '1.56404197972421574013185426e+10', 27, 6);
T('1.03654E-8829328', '-2.03302789980666878287e+7', 21, 4);
T('2.966963898883723964406622179262104271E-40046044', '-9.22094228602444715139934346e+7', 27, 6);
T('2.17861809580860432485578624E+39', '9.05795094015633624269836517536636343e+1', 36, 4);
T('8.5860E+9131106', '2.10251507082814583119796429685249702465e+7', 39, 0);
T('1.5412779579669645484712783548614741E+4221134711453', '9.7195218621118328121695164047507959011952e+12', 41, 3);
T('54.944027854626073894087463822117107421615', '4e+0', 2, 1);
T('5.89E+4068309134235820', '9.36762796618291285378e+15', 21, 1);
T('1.7782332841915159444510812658618254919081488280E-473555786043', '-1.09040249364311393587934959869e+12', 31, 5);
T('5.856153556936941211324932376345E-5610591872515871', '-1.2918865208528592e+16', 18, 5);
T('8.5879657E+4990177546', '1.1490308e+10', 8, 3);
T('6.806688317295882211444994250555E+7553266453', '1.73920387400077162987035162411978513704566862686e+10', 48, 1);
T('3.135921508105851703665460164485160881268374510455809E+807064325772890', '1.8583342856119478444383845e+15', 26, 0);
T('8.7301419368711031383740359E+35766359667870', '8.235508660190309563654957418152355352e+13', 37, 1);
T('152800352584718396.185354581216539422462692444', '3.956790857913206e+1', 16, 5);
T('2.61910077229511946E+546201856', '1.2576762523541114e+9', 17, 0);
T('7.448579204378498328767018243284618725336368289559954260E-217700846293938', '-5.0127472340860766741454583700554e+14', 33, 5);
T('7.2047727251858696241230866828095732184425269645695E+469327', '1.0807e+6', 5, 5);
T('6.218121194045431347809839E+4016425286', '9.25e+9', 3, 5);
T('3.96380380194329769560709701426464939552303967224636432913E+5456751169', '1.2564633899294436616578509015890963439260854e+10', 45, 6);
T('8.90161993871518743436E+9653801', '2.222870045956428697966183595567898564e+7', 37, 5);
T('5.87E-8679033343444315', '-1.998421279821315e+16', 17, 0);
T('7.22213E+9285', '2.1381479738372961297283e+4', 23, 4);
T('4.35089061025101631586337334243547962566776053387632747687140E+45018821795390', '1.03659668e+14', 10, 2);
T('8.9507732063667418791057293120281614104087038631714939252E-8440914505', '-1.94359239e+10', 9, 6);
T('3.090280901682869634794313045175007461412804E+841576988836944', '1.9378026291027647750230631e+15', 26, 0);
T('7.7014162551739797973497506E+702559370030249', '1.61770273e+15', 9, 5);
T('4.0025445459842369782426336331309922717E+9723', '2.238942178947647308221847e+4', 25, 0);
T('2.2341E+313775048695', '7.224937496793916263102024244423062e+11', 34, 2);
T('7.926192471441099330397999580E-784167', '-1.80560917444508379549407756805599569268569223e+6', 45, 1);
T('4.16722E-49749952', '-1.145534964251201622427e+8', 23, 5);
T('7.359482014076842029356125469162217556349E+51298586184260', '1.181e+14', 4, 3);
T('72.7973', '4.287678866602e+0', 13, 1);
T('7.458369731089099586537743665754431425332815238574619459129E+851537468000449', '1.96073748e+15', 10, 6);
T('6.811927352E+97672323', '2.248988368565745651603981641555e+8', 31, 0);
T('7.48744078897258414951220797837E+890299', '2.05e+6', 5, 0);
T('9.9786940300229550246920496767E+159423', '3.6708732373261279057236148539102006386167991e+5', 44, 2);
T('2.38741991405492015313119224178735E+9478681816955', '2.182547145295516879843288985e+13', 28, 2);
T('2.766573766937788216474557230E+30', '7.00951624371767949074247262566550894e+1', 37, 4);
T('3.62838465078525030E+7741738753458588', '2e+16', 1, 2);
T('7E+2084142509237', '4.79891547344626727113852205192e+12', 30, 1);
T('6.632399246416402141258204555971393162485E+5282951327214421', '1.216444497305703653967296294053184676613657e+16', 44, 5);
T('9.3160920091238143684430426114185923861195316789176E+9009721765428', '2.0745e+13', 5, 1);
T('9.3685E+670410418', '1.543677e+9', 8, 5);
T('2.5346294534658525082446802192095498605896343566597E+4300272406899978', '9.9017431399415154341560132628634710568864551e+15', 44, 0);
T('4.646038E+85', '1.97255748e+2', 9, 5);
T('7.11299819E+7082753304', '1.63e+10', 3, 1);
T('7.60429765973931070947601E+223343106', '5.14266508527302571586964653405e+8', 30, 0);
T('1.259774278348886756714714853102551787716753309044316124949E+712621', '1.6408707224870705769939774744309009702195e+6', 41, 1);
T('6.0261907885269058826333443505093996174E+6436400131', '1.482035899598163792393092381789529257871165943e+10', 46, 3);
T('2.30437658671337063317129505E+933', '2.15e+3', 4, 0);
T('3.513354973190022585498661637765E+7375148', '1.69819070999962638165306055501e+7', 30, 3);
T('3.59522279140903230506716479623E+86968785461810', '2.002530289601622667750807006104599119026e+14', 40, 1);
T('2.323805246716532118808402603969727E+9227297604', '2.12466e+10', 6, 6);
T('4.19231E-7592313503421', '-1.748194789431315881762449482356139169e+13', 37, 1);
T('2.824917408520510981566548810161099E-652378', '-1.502154819318141286164e+6', 22, 2);
T('9.12243E-50019117136', '-1.1517327347986588780346729255272976018954e+11', 41, 0);
T('3E+762827674466452', '1.756475631749768085398731e+15', 25, 4);
T('7.88476026918002602572814E-990381735', '-2.280438217319647492655582971583716101855286985546894e+9', 52, 3);
T('1.93876182E+451', '1.0391279265e+3', 11, 2);
T('7.3740736325E+654774', '2e+6', 1, 6);
T('7E+4834316708582532', '1.113142558799418024006562114e+16', 28, 4);
T('8.419903621598494995504679345354396264274607872E-81228', '-1.87032251335338520070667445258625347255285029857514040215222e+5', 60, 2);
T('5043072.7', '1.543352611697716150423861515247087376581267e+1', 43, 0);
T('9.967071401753478835579846245480959735737425E-30800642339454', '-7.092109991e+13', 10, 6);
T('7.9191984564270720102158323147796783178696538378E+4299108154110', '9.89906234e+12', 9, 3);
T('64572.983932271806289465556', '1.10755513969156443144229910347268775332908e+1', 42, 1);
T('1.937714E+843491028282664', '1.942209867797881766126295470773e+15', 31, 0);
T('6.9114234023582240731E+5055056421210478', '1.16396975597230781881412937544250850646634588400335279264924e+16', 60, 2);
T('4.961229890606203486886459941941277127027E+604148', '1.39110378041583852706104753424975e+6', 33, 1);
T('1.2295412035299050272723E+2703096359889097', '6.224109383e+15', 10, 4);
T('9.657371691296E+308989382', '7.1147434715436423514160983064473799366383290739381572967375e+8', 59, 2);
T('1.4128908712960608623688853001789149213438E+2145', '4.93939066234102715130453498008430346620462153038006e+3', 51, 6);
T('26144210329259503349147403065.297086', '6.54334252745142805327741060175e+1', 30, 6);
T('8.33725972357462126144877718036E-640752', '-1.47538388278e+6', 12, 0);
T('4.1590152196231371771711659246E+403232512853795', '9.284771731076797069605043792598349156233286259e+14', 46, 1);
T('9.82E+13', '3.22180273312889684123493284e+1', 27, 3);
T('7.82843348542643E+46', '1.079766767019947895265445329067662e+2', 34, 5);
T('8.811680861027610685596511333077922481897E+767481402198272', '1.7671912358519e+15', 14, 6);
T('1.2646988103492E-98338836657', '-2.264335393485497795949962419719976584598e+11', 40, 2);
T('1.540214958114481019557937E+59181121', '1.3626956743319885978e+8', 20, 6);
T('2.2618706725559597340E-80442266991491', '-1.85225164821253339576e+14', 21, 3);
T('2.25864914751234848775875033898256307911050778157110133811791E-309527450036735', '-7.127132923270444743819e+14', 22, 3);
T('2.330814534885802362082745596145962939767778133925858E+3904036936174', '8.989377251733e+12', 13, 4);
T('3.0420074653830109395743228528E+921305605563904', '2.121384553463298577109196723086986800668975639e+15', 46, 5);
T('1.0E+872', '2.0078542e+3', 8, 3);
T('1.323555869318702120137287477E-422', '-9.714105872883810124432881156687558071e+2', 37, 2);
T('4.84867115556496735086756738807727439043049075112985641565E+614778', '1.415580237005372281896918768840573147097e+6', 40, 2);
T('6833491.742', '1.57373463369279317127597002209e+1', 31, 4);
T('6.13048371442940275525618964841722738636998403233077810E-779320416', '-1.79445157073424472e+9', 18, 0);
T('6.0898902427122806E+4688', '1.07963255460151024248754967714575317203653e+4', 42, 2);
T('9.86452924549600460448324612453147245449268E+84761347812', '1.9517021593628361608673649350374236821833483200901459714e+11', 56, 0);
T('3.9176116276489746389198699E+414', '9.54635710688990638428e+2', 21, 2);
T('4.095990639970856826151360589E+22632687948659', '5.2113689884969610573321058748008149098043826274e+13', 47, 2);
T('8.39387938871195E+763256545', '1.75746314477464181041383599861e+9', 30, 0);
T('7.800050366E+62060334923', '1.428992020619717061857733637740779046196932e+11', 43, 6);
T('8.089598709221611344683604575548820409668250E+87031175958679', '2.00396688388198128829e+14', 21, 4);
T('5.10635917896490647888E+3182', '7.3284562525678883986172066777758364471375155394546945442e+3', 56, 6);
T('0.0091575773634501050584', '-4.69317361524979007029379576e+0', 27, 3);
T('7.57895891043427E+89609785', '2.0633415715277728333795242903376837197944185472408033310945e+8', 59, 1);
T('3.52931879025497378514095E-394665', '-9.087484846216199820657414e+5', 25, 5);
T('9.25007957288654366172E+74427302675', '1.71375197653435e+11', 15, 5);
T('9.689571004958528405688233E+6725552890171551', '1.54861578270520357492776037597261680823721e+16', 42, 5);
T('6.18835267180055712238377841454729349189226E+231771635055534', '5.3367391185773059667279852591e+14', 29, 2);
T('9.9940433950867406385462586629E+57', '1.33549339555687132737e+2', 21, 1);
T('5.2273640460183882551198285667311888762451852768642903877382E+86461', '1.99085e+5', 6, 1);
T('3.7574919683230201675805072575E+3940', '9.0735090181e+3', 12, 5);
T('0.3264874060', '-1.1193639037508e+0', 14, 5);
T('6.617722342369695540731E+87617', '2.01747487844113004556646596647711367404988980698550912078993e+5', 60, 2);
T('9.778534925839331822328485E+581875', '1.3398189811755800735983579926048573829203557e+6', 45, 0);
T('8.869065070E+6945', '1.599e+4', 4, 4);
T('3.13179778997337826067565187594790293739361810498E+22775780', '5.245e+7', 4, 0);
T('5.012E+3260', '7.50803923819762275176671578932335515919818e+3', 42, 0);
T('8.37869137029350445E+900', '2.07445227543587787134124946870990167444156501037595873e+3', 54, 1);
T('5.23468330E+979', '2.255886112387006112695230143368806974046102370335747e+3', 52, 4);
T('5.9982205441659493126046E+2517', '6e+3', 1, 2);
T('7E+5', '1.3458835614025541e+1', 17, 1);
T('8.36991087473514132639620816460727714124539564560E+114871900769', '2.64502326e+11', 9, 1);
T('9.9102170675767525486462268743104768E+722282888', '2e+9', 1, 5);
T('88.7213950103796184597368396487398', '4.4855e+0', 5, 1);
T('8.245971550E+8358202', '1.92454734391578027453548100134030572e+7', 36, 2);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,453 @@
var count = (function log(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
function assert(expected, actual) {
total++;
//if ( total % 100 == 0 ) log(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(n, base, result, pr, rm) {
Decimal.precision = pr;
Decimal.rounding = rm;
assert(result, new Decimal(n).log(base).toFixed());
}
log('\n Testing log...');
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
/*
Example of a log that will fail.
It results in 2.6 due to having 15 or more zeros from the first rounding digit.
*/
//T('4503599627370502', '1048576', '2.7', 2, 2); // 2.60000000000000009610279511444746656225...
T('0', '10', '-Infinity', 40, 4);
T('-0', '10', '-Infinity', 40, 4);
T('1', '10', '0', 40, 4);
T('-1', '10', 'NaN', 40, 4);
T('Infinity', '10', 'Infinity', 40, 4);
T('Infinity', '0', 'NaN', 40, 4);
T('-Infinity', 'Infinity', 'NaN', 40, 4);
T('NaN', '10', 'NaN', 40, 4);
T('1', '0', 'NaN', 40, 4); // Math.log(1) / Math.log(0) == -0
T('10', '0', 'NaN', 40, 4); // Math.log(10) / Math.log(0) == -0
T('10', '-0', 'NaN', 40, 4); // Math.log(10) / Math.log(-0) == -0
T('10', '1', 'NaN', 40, 4); // Math.log(10) / Math.log(1) == Infinity
T('10', '-1', 'NaN', 40, 4);
T('10', 'Infinity', 'NaN', 40, 4); // Math.log(10) / Math.log(Infinity) == 0
T('10', '-Infinity', 'NaN', 40, 4);
T('10', 'NaN', 'NaN', 40, 4);
T('-1', '-1', 'NaN', 40, 4);
T('0', '0', 'NaN', 40, 4);
T('7625597484987', '59049', '2.7', 2, 5);
T('839756321.64088511', '28', '6.16667503', 9, 0);
T('94143178827', '3486784401', '1.15', 3, 0);
T('243', '9', '3', 1, 4);
T('512', '16', '2.25', 7, 0);
T('512', '16', '2.25', 7, 2);
T('512', '16', '2.2', 2, 5);
T('512', '16', '2.2', 2, 6);
T('16', '2', '4', 7, 0);
T('16', '2', '4', 7, 2);
T('243', '3', '5', 7, 1);
T('243', '9', '2.5', 7, 1);
T('243', '3', '5', 7, 3);
T('243', '9', '2.5', 7, 3);
T('32', '4', '2.5', 7, 0);
T('32', '4', '2.5', 7, 2);
T('4', '2', '2', 1, 2);
T('8', '2', '3', 2, 0);
T('16', '2', '4', 2, 0);
T('32', '2', '5', 3, 0);
T('64', '2', '6', 3, 0);
T('64', '2', '6', 2, 0);
T('64', '2', '6', 1, 2);
T('128', '2', '7', 1, 0);
T('256', '2', '8', 1, 2);
T('1024', '2', '10', 2, 0);
T('1024', '2', '10', 10, 0);
T('16384', '2', '14', 2, 0);
T('16384', '2', '14', 10, 0);
T('243', '3', '5', 7, 4);
T('243', '9', '2.5', 7, 4);
T('243', '3', '5', 7, 4);
T('243', '9', '2.5', 7, 4);
T('16', '2', '4', 7, 4);
T('32', '4', '2.5', 7, 4);
T('16', '2', '4', 7, 4);
T('32', '4', '2.5', 7, 4);
T('1.2589254117', 10, '0.1', 1, 2);
T('1.023292992', 10, '0.01', 1, 2);
T('1.258925411794167210423954106395800606', 10, '0.1', 1, 4);
T('1.25892541179416721', 10, '0.1', 1, 0);
T('1.258925411', 10, '0.1', 1, 5);
T('1.258925411794167210423954', 10, '0.1', 1, 4);
/*
6.166675020000903537297764507632802193308677149
28^6.16667502 = 839756321.6383567959704282429971526703012698
28^6.16667503 = 839756349.6207552863005150010387178739013142
*/
T('839756321.64088511', '28', '6.16667503', 9, 0);
T('576306512.96177', '985212731.27158', '0.9742', 4, 2);
T('97.65625', '6.25', '2.5', 3, 0);
T('223677472.0384754303304727631735', '26', '5.900904252190486450814', 22, 5);
T('2063000845.3020737243910803079', '35', '6.0324410183892767982149330415', 29, 0);
T('302381977.956021650184952836276441035025875682714942', '2623', '2.4805663226398755020289647999', 29, 6);
T('456870693.58', '238920772.66', '1.0336035877093034523', 21, 4);
T('16', '2', '4', 10, 4);
T('32', '4', '2.5', 10, 1);
T('316.2277660168379331998893544432645719585553021316022642247511089459022980600999502961482777894980004', '10', '2.49999999999999999999', 21, 1);
// Base 10 therefore the following tests pass despite 15 or more zeros or nines as the rounding digits.
// 4.0000000000000000000173...
T('10000.0000000000000004', 10, '4.01', 3, 2);
// 4.00000000000000000173...
T('10000.00000000000004', 10, '4.01', 3, 2);
// 2.000000000000000000000004342944...
T('100.000000000000000000001', 10, '2.1', 2, 0);
// 2.00000000000000004342944...
T('100.00000000000001', 10, '2.1', 2, 0);
// 4.9999999999999999999960913...
T('99999.9999999999999991', 10, '4.999', 4, 1);
// 0.09360000000000000000000000020197...
T('124050.923004222533485495840', 10, '5.093601', 7, 2);
// 0.09999999999999999999999999999972381...
// 10^0.1 = 1.258925411794167210423954106395800606093617409466...
T('1.258925411794167210423954106395', 10, '0.09999', 4, 1);
// 8.959609629999999999999999999999431251938064
T('911191437.48166728043529900000', 10, '8.959609629999999999999999', 25, 3);
// 2.4038746000000000000000000000000268051243...
T('253.4396732554691740503010363220', 10, '2.403874600001', 13, 2);
// 3.391702100000000000000000000000000025534271040...
T('2464.348361986885121671329250344224', 10, '3.3917021', 18, 1);
T('2464.348361986885121671329250344224', 10, '3.39170210000000001', 18, 0);
// 4.0000000000000000173...
T('10000.0000000000004', 10, '4.01', 3, 2);
// 4.00000000000000173...
T('10000.00000000004', 10, '4.01', 3, 2);
// 2.0000000000000004342944...
T('100.0000000000001', 10, '2.1', 2, 0);
// 4.99999999999999999960913...
T('99999.99999999999991', 10, '4.999', 4, 1);
// 4.9999999999999999960913...
T('99999.9999999999991', 10, '4.999', 4, 1);
// 4.99999999999960913...
T('99999.99999991', 10, '4.999', 4, 1);
T('6.626757835589191227753975149737456562020794782', 10, '0.8213011002743699999999999999999999999999999', 43, 1);
T('4.20732041199815040736678139715312481859825562145776045079', 10, '0.6240055873352599999999999999999999999999999999999999', 52, 3);
T('64513410281785809574142282220919135969.8537876292904158501590880', 10, '37.80964999999999999999', 22, 1);
T('33.51145738694771448172942314968136067036971739113975569076629', 10, '1.5251933153717162999999999999999999999999999999999999999', 56, 3);
T('10232.9299228075413096627', 10, '4.009999999999999', 16, 1);
T('1.258925411794167210423954106395', 10, '0.099999999999999999999999999999723814', 35, 0);
T('1.29891281037500', 10, '0.11357', 5, 1);
T('16.399137225681149762104868844', 10, '1.21482099999999999999999', 24, 3);
T('0.01', 10, '-2', 17, 3);
T('0.0000000001', 10, '-10', 4, 2);
T('0.00001', 10, '-5', 35, 3);
T('0.00000001', 10, '-8', 24, 2);
T('0.0000100000000000010000005060000000000800030000000400908', 10, '-4.99', 3, 1);
T('94143178827', '3486784401', '1.15', 3, 0);
T('15625', '3125', '1.2', 2, 3);
T('3', '3486784401', '0.05', 1, 8);
T('268435456', '1048576', '1.4', 2, 3);
T('25', '9765625', '0.2', 1, 7);
T('524288', '256', '2.375', 4, 8);
T('177147', '81', '2.75', 3, 5);
T('531441', '59049', '1.2', 2, 8);
T('387420489', '59049', '1.8', 2, 6);
T('16384', '65536', '0.875', 3, 6);
T('31381059609', '59049', '2.2', 2, 5);
T('8589934592', '65536', '2.0625', 5, 3);
T('33554432', '256', '3.125', 4, 3);
T('4503599627370496', '65536', '3.25', 3, 3);
T('68630377364883', '59049', '2.9', 2, 3);
T('68630377364883', '847288609443', '1.16', 3, 5);
T('16', '1125899906842624', '0.08', 1, 2);
T('3814697265625', '390625', '2.25', 3, 8);
T('8', '4294967296', '0.09375', 4, 1);
T('22876792454961', '59049', '2.8', 2, 2);
T('32', '33554432', '0.2', 1, 2);
T('16', '1125899906842624', '0.08', 1, 2);
T('16777216', '1024', '2.4', 2, 2);
T('31381059609', '3486784401', '1.1', 2, 4);
T('131072', '16', '4.25', 3, 7);
T('17179869184', '65536', '2.125', 4, 2);
T('131072', '32', '3.4', 2, 5);
T('31381059609', '6561', '2.75', 3, 4);
T('1162261467', '81', '4.75', 3, 2);
T('5', '152587890625', '0.0625', 3, 8);
T('2048', '32', '2.2', 2, 5);
T('15625', '390625', '0.75', 2, 0);
T('3125', '390625', '0.625', 3, 8);
T('17592186044416', '65536', '2.75', 3, 4);
T('4194304', '1048576', '1.1', 2, 2);
T('125', '390625', '0.375', 3, 5);
T('134217728', '256', '3.375', 4, 2);
T('762939453125', '625', '4.25', 3, 7);
T('8', '4294967296', '0.09375', 4, 0);
T('4', '1125899906842624', '0.04', 1, 5);
T('2384185791015625', '390625', '2.75', 3, 7);
T('4', '1024', '0.2', 1, 2);
T('268435456', '1048576', '1.4', 2, 8);
T('17592186044416', '4294967296', '1.375', 4, 0);
T('32', '4294967296', '0.15625', 5, 7);
T('256', '32', '1.6', 2, 2);
T('531441', '59049', '1.2', 2, 3);
T('67108864', '1048576', '1.3', 2, 2);
T('3814697265625', '3125', '3.6', 2, 5);
T('4096', '1024', '1.2', 2, 6);
T('78125', '625', '1.75', 3, 3);
T('1162261467', '81', '4.75', 3, 1);
T('4782969', '6561', '1.75', 3, 0);
T('4', '1024', '0.2', 1, 1);
T('59049', '6561', '1.25', 3, 2);
T('1024', '1099511627776', '0.25', 2, 2);
T('134217728', '1048576', '1.35', 3, 4);
T('65536', '32', '3.2', 2, 5);
T('19073486328125', '9765625', '1.9', 2, 2);
T('19073486328125', '3125', '3.8', 2, 5);
T('34359738368', '65536', '2.1875', 5, 4);
T('387420489', '59049', '1.8', 2, 1);
T('1125899906842624', '1099511627776', '1.25', 3, 3);
T('4', '1024', '0.2', 1, 8);
T('3125', '95367431640625', '0.25', 2, 4);
T('9', '6561', '0.25', 2, 0);
T('456870693.58', '238920772.66', '1.0336035877093034523', 21, 4);
T('575547956.8582', '824684975.3545', '0.98248076', 8, 4);
T('82275648.874341603', '959190115.624130088', '0.88124641544168894893181429200832363', 35, 4);
T('74257343.4', '743703514.4', '0.88720377341908842250463392057841865999040289364224', 50, 4);
T('617556576.22', '1390349767.37', '0.96145220002205342499', 20, 4);
T('385659206.402956', '306197094.245356', '1.0118079926535367225661814147003237994862', 41, 4);
T('1739848017', '139741504', '1.134455757605027173760473871049514546484', 40, 4);
T('684413372.332', '749444030.62', '0.99556', 5, 4);
T('1276559129.76358811', '1814329747.19301894', '0.983510102095361604388', 21, 4);
T('470873324.56', '770017206.95', '0.975963952980122531477453931545461086248352', 42, 4);
T('142843622.855', '188030025.676', '0.985573716314165', 15, 4);
T('208762187.506204', '15673510.715596', '1.1563', 5, 4);
T('1066260899.1963', '954219284.761', '1.005369396783858165862954752482856604', 37, 4);
T('98615189.15', '75483684.05', '1.0147363402964731399253', 23, 4);
T('134306349.93018997', '262971762.95484809', '0.965342550919082621945239', 24, 4);
T('964681161.089224', '1910911588.814815', '0.9680153968863558918522522557796148', 34, 4);
T('9303669', '272208139', '0.8262', 4, 4);
T('388804210', '196979048', '1.035603565223696855965', 22, 4);
T('699589959.2322617', '574032511.7854473', '1.0098079347111332288609', 23, 4);
T('100575245.36', '172874206.82', '0.971443699412905370317336892965778', 33, 4);
T('188632711.8541175', '1056627336.0975408', '0.9170754305183363941127042', 25, 4);
T('267522787.94', '528716571.79', '0.966083390988836341228896', 24, 4);
T('145509306.43395', '472783713.04935', '0.941003844701466585568051857', 28, 4);
T('991525965.6381098', '609527830.0476525', '1.024053580832128', 16, 4);
T('1023653880.6218838', '953120602.1428507', '1.00345303146', 13, 4);
T('55755796.19', '1330531177.01', '0.84899920538009273', 17, 4);
T('334096229.1342503', '563056758.6770503', '0.97409528', 8, 4);
T('9635164', '231514430', '0.834932623823994616103829175346875687708', 39, 4);
T('131654133.157309973', '115412751.259558256', '1.007092396906741330059871530698890891053443', 43, 4);
T('28107031.16903', '323908252.33297', '0.87525800295707725472', 20, 4);
T('942124652.44', '686394876.98', '1.01556421460608796561', 21, 4);
T('134207809', '170927649', '0.9872419619471883239821215', 26, 4);
T('198609255.296', '765215848.971', '0.9340613778607868792216981337564', 31, 4);
T('664631640.1191', '376279805.8674', '1.0288111231512597915756117213', 29, 4);
T('647566101.164328642', '407052201.855466296', '1.023419534517733289078130759686', 31, 4);
T('242605467.6', '3268140.5', '1.287152826698319781357494634688', 31, 4);
T('5396771.02937553', '1411282.60639346', '1.0947246452397777430415523165413422902424568', 45, 4);
T('6228580.16566', '453960426.11951', '0.7848417390817178840972620893811037531107708294', 46, 4);
T('878490932.5', '189566553.9', '1.080453580440657158456', 22, 4);
T('1500680766.6371536', '1494780181.6442677', '1.0001864920020959610926036', 27, 4);
T('173605161', '989556046', '0.91597101071520992883356353020920075841', 38, 4);
T('570910553.14918', '616094822.16082', '0.996236539891160511560385433132728465017198', 42, 4);
T('37195924.394254207', '127531072.030845613', '0.9339814946288269', 16, 4);
T('22164450.211923', '243265988.586396', '0.87593437485408990967662593016805664894656', 41, 4);
T('175111472.895051078', '561767815.122048785', '0.94214081222679273276622917511607118811', 38, 4);
T('92702966.55', '562074647.894', '0.910546423686847055179464329092669', 33, 4);
T('260084613', '160581316', '1.0255212564415', 14, 4);
T('213030852.3', '47040534.8', '1.08549659522166864397502645463300419005653', 42, 4);
T('1327668611.05913', '848611793.9525', '1.02177029434766261729', 21, 4);
T('66944433.91', '37665148.37', '1.03296947987902231513689373', 27, 4);
T('333313135.0827385', '147427566.3086553', '1.043370303', 10, 4);
T('756767858.792642', '513855352.06323', '1.019', 4, 4);
T('551590228.4822', '253966714.4708', '1.04007718126961747868602448117617608919458655503', 48, 4);
T('1882211388.983751503', '1593467634.878447375', '1.007859427551369756176720215269895309219252795831', 49, 4);
T('496604846.993369651', '1250937096.045637042', '0.955895995137179786819967061075092', 33, 4);
T('460938387.41106403', '892723899.76771112', '0.97', 2, 4);
T('1208583543.0755', '1801535412.788', '0.981269142418459120915', 21, 4);
T('71809284.33940128', '1599263904.61399344', '0.853568966592640560288310566832707', 34, 4);
T('165181894', '197693262', '0.9905943222681096997828', 22, 4);
T('172342892.2755695', '1013895675.5730544', '0.91454580627089536191594420786355067402436333108', 47, 4);
T('76327930.1691', '605058531.8951', '0.8976161867656397914685427265032120246028151', 44, 4);
T('157359823.532684', '53839744.709721', '1.060248953923960673498498182556874', 35, 4);
T('278952919.13814458', '409957472.74412763', '0.980585978464508766054991193215240504363', 39, 4);
T('1258423560.1', '1619810525.2', '0.98809514066162', 14, 4);
T('798939732.686433', '1672296635.208782', '0.96521864919758039929', 20, 4);
T('334706290.845', '330433505.915', '1.000654976135280091123085197917', 31, 4);
T('921610727.8', '1683508825.7', '0.971638655200833693263145748073', 30, 4);
T('91469509.55', '84500848.95', '1.0043416023016102807100081454879', 32, 4);
T('1238654120.34', '419789841.51', '1.0545', 5, 4);
T('779032702.616761', '656872953.495305', '1.00840084663', 12, 4);
// base 2
T('26880.2432276408875624', 2, '14.7142585720457255', 19, 3);
T('18216.8140929585641372', 2, '14.152983050314836771855701', 26, 1);
T('28062.73494235358182', 2, '14.776367997755111083362495', 26, 0);
T('7408.82842447993', 2, '12.8550297084583087071', 21, 1);
T('395.067', 2, '8.62595353', 9, 3);
T('27442.6587462411378', 2, '14.74414', 7, 0);
T('29259.23925137426', 2, '14.83660463902', 13, 1);
T('31809.09321', 2, '14.95715162', 10, 3);
T('21088.306138691278', 2, '14.3641556', 9, 4);
T('21417.99322', 2, '14.386535691235055367', 20, 4);
T('30749.008158228314845157', 2, '14.9', 3, 3);
T('11701.5', 2, '13.51440585840535244680127', 25, 0);
T('31737.6741', 2, '14.954', 5, 2);
T('1688.88816886', 2, '10.7218580867075137099751634', 27, 3);
T('31553.4', 2, '14.945507849063278420302384', 26, 1);
T('28215.19', 2, '14.7841844442', 12, 3);
T('6080.97', 2, '12.57008575', 10, 1);
T('575.881932366571406', 2, '9.16962924962079798', 18, 1);
T('4573.55560689675', 2, '12.1591004766309775332', 21, 1);
T('24202.85989198517539', 2, '15', 2, 4);
T('18334.9', 2, '14.16230477704721387108079127958', 31, 4);
T('20179.623017', 2, '14.4', 3, 0);
T('8607.97004888426002071', 2, '13.07145734276093159769689946319', 31, 1);
T('27231.463745', 2, '14.732986911725376996874804951679', 32, 3);
T('24325.08', 2, '14.57015693', 10, 0);
T('826.3541073', 2, '9.69', 3, 3);
T('6877.51851488', 2, '12.7476724030697', 15, 3);
T('13510.031', 2, '13.7217433646123774736072103937', 30, 4);
T('559.1647711259', 2, '9.12712965971023632', 18, 1);
T('1262.018796786493279', 2, '10.30151768', 10, 3);
T('31897.9889', 2, '14.9611778475691091525075', 24, 1);
T('24187.818942357666924548', 2, '14.561', 5, 3);
T('7233.846688339241', 2, '12.820547306996872048936910678432', 32, 3);
T('10162.3041', 2, '13.31093992111', 13, 4);
T('9091.859714971663525', 2, '13.1503597085807068872335', 24, 1);
T('16205.492', 2, '13.984195201', 11, 3);
T('17578.3501161869916711', 2, '14.101512046680555', 18, 3);
T('5661.58', 2, '12.466989012642603919950322048', 29, 1);
T('6674.6', 2, '12.704465665236394967162', 23, 3);
T('5063.035517', 2, '12.305786889', 11, 1);
T('10067.374870965783416', 2, '13.297399920454024702032', 23, 3);
T('22864.071031662628282003', 2, '14.480794683114196339697931635', 29, 0);
T('15588.7831039333836277142', 2, '13.9282207', 9, 0);
T('17513.7015', 2, '14.09619640742934', 16, 2);
T('6136.604218568458', 2, '12.58322482425266756363155737198', 31, 0);
T('26016.619885247', 2, '14.667145916871983257557509389', 29, 2);
T('3486.883295195387', 2, '11.76772236306965954', 20, 1);
T('29853.4019880856169328', 2, '14.9', 3, 4);
T('32174.410652492293356508', 2, '14.97362610199656', 16, 0);
T('10790.71404', 2, '13.3975027131319239178743446', 27, 4);
T('3869.9702839155983', 2, '11.918106773147484057', 20, 3);
T('14572.9804731649161632826', 2, '13.831008347831373539', 20, 1);
T('3530.1698', 2, '11.7855218629818768241', 21, 3);
T('24098.35633479612268105', 2, '14.55664712', 10, 3);
T('9625.5360719', 2, '13.23', 4, 3);
T('21545.8', 2, '14.395', 5, 3);
T('19975.55193', 2, '14.28594774531463052', 19, 3);
T('11981.45533497274', 2, '13.548515', 8, 3);
T('2944.587874', 2, '11.52386', 7, 0);
T('17730.0672623', 2, '14.11391038892776450560262608325', 31, 3);
T('27232.2', 2, '14.7330259172334297642766', 24, 0);
T('16141.46080336', 2, '13.9784835280781625406', 21, 3);
T('22862.35', 2, '14.48068608402465290616804821871', 31, 3);
T('19701.97134401560579604', 2, '14.26605237', 12, 2);
T('1582.14854859', 2, '10.62766934', 10, 1);
T('11629.28476612279', 2, '13.505474749', 11, 3);
T('12024.272', 2, '13.553', 5, 1);
T('30287.02241583997417078439', 2, '14.88641213011400845046', 22, 3);
T('10681.405529866718069', 2, '13.38281387840546429058', 22, 4);
T('17028.3', 2, '14.055647', 8, 2);
T('31450.5123172489', 2, '14.940795897815678146773997', 26, 2);
T('10267.630410391621', 2, '13.325815651', 11, 2);
T('30041.03308734805248601613', 2, '14.874646806395182486207', 24, 2);
T('9098.63993126244373708', 2, '13.1514351913945', 15, 4);
T('30885.4583445139003016', 2, '14', 2, 3);
T('1771.1692', 2, '10.79048632416067', 16, 0);
T('31464.3', 2, '14.9414282265508731233', 21, 0);
T('22935.2', 2, '14.485275867643', 14, 0);
T('8314.31328', 2, '13.02138139382', 14, 3);
T('16288.48033937', 2, '13.991564391078708126', 20, 4);
T('16341.375474', 2, '13.9962418015', 12, 3);
T('29335.7329578096819103831', 2, '14.840371417967011524840917', 26, 4);
T('22186.7391341699826076', 2, '14.437411', 8, 0);
T('4148.563221253323604', 2, '12.01839605666979644655634094031', 31, 2);
T('30958.95586132340163', 2, '14.9180691947303244998231', 24, 4);
T('27227.216131376', 2, '14.73276186', 11, 4);
T('2893.149172764447', 2, '11.498', 5, 4);
T('11428.90884008455568467895', 2, '13.4804', 8, 4);
T('6665.09', 2, '12.702408641', 12, 1);
T('23660.7112925', 2, '14.5302058244333', 16, 1);
T('15779.58', 2, '13.94577118566247809264782829', 28, 2);
T('24758.13481636580123', 2, '14.595615011042757456588', 23, 2);
T('21545.2581', 2, '14.4', 3, 0);
T('8445.30210341451', 2, '13.0439333163687263747352981', 27, 1);
T('19723.89194345160270028329', 2, '14.2676566337760362079360509651', 30, 3);
T('8131.76680164600944819', 2, '12.98936', 7, 0);
T('10409.9459240778764723', 2, '13.35', 4, 4);
T('23008.0741775', 2, '14.48985261166230230904434431', 28, 0);
T('27113.61586019', 2, '14.7268', 6, 0);
T('18807.87914187401201', 2, '14.199', 6, 1);
T('14724.76659275464725898566', 2, '13.8459', 6, 1);
T('32358.7', 2, '14.981', 5, 1);
T('8736.77', 2, '13.092884295936739139012765', 26, 0);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,559 @@
var count = (function log10(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
function T(arg, expected, pr, rm) {
total++;
Decimal.rounding = rm;
Decimal.precision = pr;
var actual = new Decimal(arg).log().toString();
//if ( total % 100 == 0 ) log( total);
if ( expected !== actual ) {
error('\n Test number: ' + total + ' failed');
error(' Expected: ' + expected);
error(' Actual: ' + actual);
error(' precision: ' + pr );
error(' rm: ' + ['UP', 'DOWN', 'CEIL', 'FLOOR', 'HALF_UP', 'HALF_DOWN', 'HALF_EVEN'][rm]);
log('');
//process.exit();
} else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
log('\n Testing log10...');
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: 0,
toExpPos: 0,
minE: -9e15,
maxE: 9e15,
errors: true
});
T('4841183675443663188762.78', '2.16849516e+1', 9, 0);
T('2.2001084261754258861227E-824263894', '-8.242638936575559156644572542921e+8', 31, 6);
T('9.841678323183423382979E+889', '8.8999306917e+2', 11, 2);
T('6.674865349047819300515860303037383179383821E-556564097058', '-6e+11', 1, 4);
T('8.45466498447465675136763E+70601305204', '7.07e+10', 3, 2);
T('4.0697767991474535745859451E+8734161', '8.7341616095705916437228490323670178068211817e+6', 44, 2);
T('6.70979951730012416235067887E-4547', '-4.546173290455960817819339e+3', 25, 5);
T('1.961351051236741863413961315199797E+4394416', '4.3944162925e+6', 11, 1);
T('1.20350E+4555', '4.55508044609461104879595186822027e+3', 33, 1);
T('5.343396356119981189485859467758323594750088722349E+24892595', '2e+7', 1, 5);
T('2.7775691E+2645806266', '2.64580626644366e+9', 15, 5);
T('1.764240941317483253710000989961978299234E+5939', '5.93924655789618074686663713956005233457194e+3', 42, 4);
T('8.68143916033713750663285740502710E+89575', '8.95759385917261e+4', 15, 5);
T('2.0184251149898158170597E-39207177567322', '-3.9207177567321694987359e+13', 23, 0);
T('7.8630374961E+539873632527965', '5.39873632527965895590346671032e+14', 30, 0);
T('1.770739036205380713465840899E+522651', '5.226512481545614797481e+5', 22, 5);
T('56.141270516453102320117316389420550463886324330', '1.74928223679933121812e+0', 21, 1);
T('2.6E+5789', '5.78941497334797081796442024405e+3', 30, 6);
T('8.407507657913886653E-27559', '-2.755807533272843934770788577111161e+4', 34, 2);
T('4.1537022577487997501227235564273504628803975515504335733E+8622517869456', '8.622517869456618435362577e+12', 25, 4);
T('3.726614237233359549085256054317096792396039592E+7200803438362342', '7.20080343836234257131444e+15', 24, 6);
T('3.07938388321764455968132812427213516E+38172329267940', '3.817232926794048846383244686011975e+13', 34, 5);
T('8.6068240435353592489E+94696427410', '9.469642741e+10', 10, 5);
T('9.37151210825471283E-865158860842', '-8.65158860841028190329358923938336e+11', 33, 1);
T('34073473340739909295181032371.558228583698065018839103', '2.853241641e+1', 10, 0);
T('2.28321371080052769522193640E+397673232597', '3.976732325973585465637362e+11', 26, 6);
T('5.53931220752051773202347E+2499', '2.499743455843605290956496e+3', 25, 3);
T('5.4924555890498123253396556014992712521439747540053861140793E+504', '5.047397665539842493968484323e+2', 28, 4);
T('4.914452734123226135400656595986723583025E-1514546', '-1.514545308524837502946553307e+6', 28, 4);
T('4.215555113580235490775E+55076305', '5.507630562485e+7', 13, 4);
T('1.3930997480622E-57275499306', '-5.7e+10', 2, 6);
T('85038.039893969528357085115812100515349', '4.929613241248970252641e+0', 22, 5);
T('7.047729155038798766423401020155837037817938179206464104E+488246', '4.8824684804920574277260014554145031e+5', 35, 3);
T('3.88173E+2768', '2.7685890253240487e+3', 17, 1);
T('6.33149E+1646322918853513', '1.646322918854e+15', 13, 5);
T('6.43213140539E+60', '6.080835490826104516024510232434e+1', 31, 6);
T('5.050356774201666667327888987E+215326920301064', '2.1532692e+14', 8, 6);
T('2739258.451754141451285499174145021701678302438665131045', '6.4376330103e+0', 12, 5);
T('1.7192003502495036108123878166266976088E+7685', '7.685235326490961406452549530538800289e+3', 37, 6);
T('9.6E+85774181', '8.57741819822712e+7', 15, 5);
T('1.87124860546679312974E+3052798657448', '3.052798658e+12', 10, 0);
T('3.083315086E-33', '-3.251098209216645436858e+1', 22, 4);
T('7.2156825787920272800526474440273278298991942831883189391E+61531910219648', '6.153191021964885827742013e+13', 25, 1);
T('8.468E-3306315551035784', '-3.306315551e+15', 10, 2);
T('4.69070189E+72479', '7.24796712378329382129172143247016859e+4', 36, 1);
T('3.35742E+835737', '8.35737526005673173223374107868535147886e+5', 39, 5);
T('3.45402661747687024737712705E+1600722944676', '1.60072294467653832568001163266841e+12', 34, 1);
T('4.7922316977869430764493052417197764722676671E+2312846442', '2.3128464426805378074275316244e+9', 29, 6);
T('9.851193152845829667E+66954099', '6.69541e+7', 9, 0);
T('1.1854901245488693749594005242978061319893665204E+36534622', '3.6e+7', 2, 1);
T('2.36333459535347419E+18828941140', '1.882894114037352521237663e+10', 25, 0);
T('3.85857292671500073837429E+902683316', '9.026833165864267128e+8', 19, 6);
T('9.6016490111491709821226489279E+51808023', '5.1808e+7', 6, 4);
T('5.17351178517133458351944997054985443108308070481852782E+72447629057', '7.2447629057713785442739598355e+10', 29, 4);
T('1.110105859069230266011E-30284901880', '-3.0284902e+10', 8, 5);
T('9.048827409E+7267517760358', '7.267517760358956592304863221501460291e+12', 39, 1);
T('1.088912795176892276835248776534961914045425466464600675903E+31952', '3.1952036994e+4', 11, 2);
T('970.687987526534321426239801143994613178912', '2.9870796551693774977726248e+0', 26, 0);
T('1.96809E+340418195', '3.4041819529404495466933301447841666e+8', 35, 0);
T('6.86872871627264284462705542579681663626E-9', '-8.1631e+0', 5, 2);
T('9.67348055315179509539189364657869462004005689059E-35611', '-3.561001441723707953133e+4', 22, 5);
T('1.8744707925587479720553595210808247818401843056803276529372E+810679', '8.1067927e+5', 8, 1);
T('8.942329972495772937474882956276E-40155184557896', '-4.015518455789504854931e+13', 22, 5);
T('5.012575871519977416116054585544633184998370041087525008E+73424', '7.34247e+4', 6, 5);
T('7.683518340090388031524844343382673720835893274744999E+2054546124012473', '2.05454612401247388556013e+15', 24, 5);
T('3.815810146227322026775444113884081509750E+36773121563', '3.67731215635815867584594686290771255e+10', 36, 5);
T('7.4861378005232013255069E+1485805', '1.485806e+6', 7, 0);
T('9.07761360146935072886298392797676264735146941104416705855E+5852', '5.85295797169258163209871826529944651947e+3', 39, 4);
T('3.4888777700553647252456603687651697829004766607593E+790861779850044', '7.9086177985004454268575e+14', 23, 4);
T('7.6776640508986078666E-160824', '-1.6e+5', 3, 1);
T('6.0310855923559920575167841704099767E+220096231795', '2.20096231796e+11', 12, 0);
T('5.354591927609993818150377979653E+206804676737', '2.06804676737728726e+11', 18, 1);
T('6.635487235E+6294451574004', '6.29445157400482187e+12', 18, 3);
T('8.8584E-7247204157652366', '-7.2472041576523650526447131e+15', 27, 3);
T('3.565918492306569022483822438092572617805207953592E+730255', '7.302555521714121e+5', 16, 4);
T('354539328516823449672.983298997050733493', '2.054966441782787142944577776331757526e+1', 37, 4);
T('5.1031831539356080897895506E-82341', '-8.2340292158844500189385823717987586e+4', 35, 0);
T('9.3648851529395696724E+3631', '3.63197150245573683604e+3', 21, 6);
T('9.353521E+1822', '1.822970975e+3', 10, 5);
T('7.93249517949211819801840221693753800779017848E-53570', '-5.356910059018314442492287309e+4', 28, 3);
T('51.59851352524098568099996391240738929', '1.712637190443409949195148634e+0', 28, 5);
T('8.69810649237836206E+4576415322', '4.57641532293942472050213e+9', 24, 1);
T('5.743720268213722512570210325542067E+58', '5.8759193280654602219732387e+1', 26, 3);
T('8.619379022453270498382221769546056490709529450344410959315E+47788560', '4.77885609354759784887019304047e+7', 30, 5);
T('6.544820735E+43543', '4.35438158977555672160892806801649648482e+4', 39, 6);
T('9.7140458707335387296463547584212801920234541874110852E+56136', '5.613699e+4', 7, 0);
T('670.08557647535', '2.8261302698e+0', 11, 1);
T('8.3343821492312863357729036128803472E+20716943608421', '2.0716943609e+13', 11, 2);
T('8.0445178773508301187593293762052E-5077691', '-5.077690094499978846538805108623135e+6', 34, 3);
T('22.767730836345951349056967', '1.3573198e+0', 8, 2);
T('7.457764361860907275E+83607531272', '8.360753127287260865712126e+10', 25, 6);
T('3.415842397810612774258963557343915245829E-783248777', '-7.8324877646650217526059645247e+8', 29, 5);
T('6.781552710927048827039026094701379639485822363E-63935527', '-6.39355261686708582592412650368413182e+7', 36, 5);
T('6.18215839966859296918377E-95603', '-9.560220885987160841432001e+4', 25, 1);
T('9.4568E-890882', '-8.90881024255795675e+5', 18, 5);
T('5.1258099656456511679058622861734211977997669237E-5298117838', '-5.298e+9', 4, 1);
T('6.29591891528059956655696230115941216487334752792035E-1099146', '-1.0991452009408738626139726375999e+6', 32, 3);
T('8.0754743E-772876752955', '-7.7287675295409283196066e+11', 23, 0);
T('1.469473602473045923603275116E-3456356954867', '-3.4563569548668328382111587476011e+12', 34, 6);
T('5.275444573067300813303017433E+1246343974825', '1.246343974826e+12', 13, 0);
T('9.357019981170384806302965944044067572833526212960677676185E+919738937', '9.197389e+8', 7, 6);
T('3.9438932490723162010961026802042639423318395E+81451', '8.1451595925151206732965697738591566e+4', 35, 6);
T('8.6846426025687648324E+5885', '5.886e+3', 5, 0);
T('5.9725023280777779427848795005502784720E+15955137', '1.59551377761563277e+7', 18, 6);
T('4.9108147887698410693495984791291047177096873731080442999E+256', '2.566911535550373155e+2', 19, 4);
T('7.7891782748328973413016239994909833278529860E+5147735', '5.14773589149164386906993465073054e+6', 33, 6);
T('1.3446738004511849218508667329449356E-104', '-1.0387e+2', 5, 6);
T('9.4585604116535644814652908019807413769068321E+8657106925648', '8.6571069e+12', 8, 3);
T('473796.95276', '5.675592263217112e+0', 17, 2);
T('6.7975863449656604442210773071454621832E+911843', '9e+5', 1, 6);
T('3.246E-892605', '-8.92604488651484509786930611884958125035e+5', 39, 0);
T('7.95794039837E+53', '5.3900800682139352423105080345e+1', 29, 6);
T('5.678427235419145307694573911035564508172906E+947452164', '9.474521647542280650134995059521995e+8', 34, 1);
T('8.0029879722391808789882801725596316284E+390572713525', '3.905727135259032e+11', 16, 3);
T('5.9907384197073313096317126931E+438', '4.388e+2', 4, 0);
T('9.780224646978402584108429856691E-991154968270', '-9.9115496826900965116956591580413645e+11', 35, 0);
T('4.0789430894606339087011E-68068516', '-6.806851538945235403706815e+7', 25, 4);
T('6.27212568421917649954621498988165460E+964956854808', '9.64956854808797414752389e+11', 24, 3);
T('8.1285688633483981E+10047259786', '1.004725978691001408932568816558895806e+10', 37, 6);
T('3.1728152468829356912309147407245214539710141133899042E+1655257278', '1.655257278502e+9', 13, 0);
T('9.176094625036158762929748341685687808135628065919022704611E+754162756635', '7.54162756635962657883415352047953e+11', 34, 6);
T('1.7913862265763242730616208060249388655022492727773301E-239576700616', '-2.3958e+11', 5, 5);
T('8.75596177370E+15252741413', '1.525274141394230385688088809408546e+10', 34, 5);
T('7.484860784482E+8186', '8.18687418372e+3', 12, 1);
T('7.4550422084407536881639416021211E+31334619524362', '3.2e+13', 2, 0);
T('338.0180791974408458407648664273', '2.52893992952530145949164e+0', 24, 1);
T('111.522870347581464280157552128257477754581', '2.047363938659902688627435e+0', 25, 5);
T('8.7234E+6747953961417', '6.747e+12', 4, 3);
T('5.078468711341770084967E+877358148263834', '8.7735814826383470573278108977878e+14', 32, 2);
T('2.341942200530809328432361125802E+11440534189151', '1.144053418915136957617241854576e+13', 31, 0);
T('3.39486879133784644485267648691675642751667E+179533', '1.79533530823e+5', 12, 4);
T('8.92409276216985731888299548546727483294336E-906957612', '-9.0695761104943592405728109779e+8', 29, 2);
T('6.1439191715203256047657562390017034647E+7017', '7.01778845e+3', 9, 6);
T('0.0607565815281965620', '-1.21640666972047895359738631018593e+0', 33, 1);
T('1.26909860997369767419453053919499402281899674939E+90874', '9.08741034953684332361358740036169927e+4', 36, 4);
T('8.0331252127E+293887', '2.9388790488453638465032e+5', 23, 6);
T('2.30551730283257381646749362695831153232E+690979756252091', '6.9097975e+14', 8, 1);
T('4.834354800443539089821414753900904180773116496518816E+406287936', '4.062879367e+8', 10, 2);
T('9.78143205772408908E+8880', '8.8809904e+3', 9, 3);
T('7.20267097210042335643600516492543902753411809195260386415528E-843', '-8.421425064239384218021880814198309397e+2', 37, 6);
T('5E+8794086216615750', '8.794086216615750698970005e+15', 25, 0);
T('2.2230867570633275409316194970723911385E+42569127', '4.25691e+7', 6, 5);
T('4.05179770267110143930997262E+6702495011458367', '6.702495e+15', 8, 6);
T('8.8769455861184153541120093E+14381620996623', '1.438162099662394826355775109194182e+13', 34, 1);
T('5.55E+67416654', '6.741665474429298312268e+7', 22, 0);
T('9.936193379889E+9340', '9.340997220035227980491424693376424e+3', 34, 4);
T('1.6293380311554057252084909989087523183E-629443289410211', '-6.294432894102107879888052949467041124e+14', 37, 1);
T('6.535720212535925818263E-6016865', '-6.016864184706547778054995494541617498e+6', 37, 5);
T('8.26030664595E+27993', '2.8e+4', 2, 4);
T('8.58844737E-64797968909', '-6.47979689081e+10', 12, 6);
T('2.89074766828843309E+80683', '8.068346e+4', 7, 4);
T('5.914787661096986461920174515416305183764410E-229133', '-2.2913222806084178315871148029698774e+5', 35, 4);
T('6.611970244E-8755011013', '-8.756e+9', 4, 3);
T('4.7499572E+9079499490292', '9.07949949029267668969638538e+12', 27, 5);
T('6E+89592077', '8.959207778e+7', 10, 6);
T('2.8939846181700349595255006347368997997E+245588275', '2.455882754615e+8', 13, 2);
T('9.72535836507884579605194672928453281902058875E+961918318165', '9.619183181659879056134e+11', 22, 1);
T('1.802571230724667168480756934002949337067746121E+42330194', '4.2330194255892435388381046734221557465e+7', 38, 2);
T('1.291996644845554714675888790E+329589440762', '3.295894408e+11', 10, 4);
T('1.057909734340004695619340250E+391253093', '3.91253094e+8', 9, 2);
T('8.9822369527734239294875384027479645330225153967804276E-700117169572369', '-7.001171695723680466155e+14', 22, 0);
T('7.45867503089770208658991644494696036321625401664926340E+3178562323202', '3.1785623233e+12', 11, 0);
T('9.347942753E+9361211', '9.3612119707160440997000626e+6', 26, 2);
T('1.21145320194702852291842307817094E+1899683', '1.89968308330664213946e+6', 21, 4);
T('4.46661546613826630813244418390131151141E-623', '-6.22350021434616288e+2', 18, 5);
T('1.4E+9', '9.14612803567823802592596e+0', 24, 2);
T('4.5E+97105311', '9.71e+7', 3, 3);
T('4.201530151746487591796293480191397700881554324272425E+723480211317860', '7.23480211317860623407484e+14', 24, 3);
T('1.762216E-864', '-8.63753940859908806915202533635e+2', 30, 2);
T('8.642227400751456E+6087945602262', '6.0879456022629366256e+12', 20, 1);
T('6.523314129677137548107192190002930715248594495481671162E+598', '5.988144682924425501602464837799e+2', 31, 6);
T('2.2403991884402140E+24395579910347', '2.44e+13', 3, 6);
T('1.6557366956033476E+70057240', '7.0057240218991274031917e+7', 23, 6);
T('9.9343328233987582609641213169601E+15633099572', '1.56330995729971387057e+10', 21, 1);
T('7.68263067382226322729272701061395977949395460570024940310836E+10175', '1.0175885509955903658e+4', 20, 2);
T('8.21658797619717429167944100449766461100777451E+167541', '1.6754191469150966433790137774168e+5', 32, 4);
T('8.274172700943149949248680999419886629978E+55223547', '5.5223547917724581375045860432e+7', 29, 3);
T('4.459590759E+2120225', '2.12022565e+6', 9, 5);
T('2119293200287310544361006449292.097790087086884621200104', '3.03261910447042660599268663431444993e+1', 36, 6);
T('9.648537852327574E+137078236442', '1.37078236442984461504973030348183e+11', 33, 3);
T('5.7903459194922814675456E-9701270005', '-9.701270004237295490428153e+9', 25, 4);
T('7.342558758386103195254009211254457570228171605E-4943687121', '-4.9436871201341525694e+9', 20, 0);
T('2.282545429409039868294662520556324477527757977536E+6695763172262261', '6.69576317226226135841943003780236539e+15', 36, 4);
T('8.4985445E+5296565596620', '5.2965655966209293445529e+12', 23, 2);
T('6.66867820057434922039563598610448084365023382055459E+7882014', '7.88201482403976089e+6', 18, 4);
T('7.6622494809303404482041186857493199308751059E-70020501626429', '-7e+13', 2, 5);
T('7.98673156225E-75063484', '-7.506348309763091216108166285e+7', 28, 0);
T('5.232969470376787870655528179123539518571846237E+95896', '9.589671875e+4', 10, 5);
T('1.239584E+881548295', '8.81548295093275961924e+8', 21, 2);
T('1.8882461259780200932716727517429440850023951693614993E-29676693042490', '-3e+13', 2, 3);
T('3.5413691828218E-9', '-8.4508287962848912e+0', 17, 6);
T('9.58573533146370355175749633935031597475E+32021008', '3.2021008981625433661436e+7', 23, 6);
T('792761.93385093612011907717194655264284481632519605064178', '5.89914278840534e+0', 15, 0);
T('6.3955989097974232284047639485531180916376215E-57323114414217', '-5.7323114414216194118780185915422e+13', 32, 3);
T('6.9019088922329566961649111017E-632349784', '-6.323e+8', 4, 4);
T('4.62685910E-480838608091', '-4.80838608090334713725705251106331291e+11', 37, 6);
T('8.311855917119072957E+7154', '7e+3', 1, 6);
T('4.8159504049967133953919395504883957993255351483817314E+405363840', '4.0536384068268200587701e+8', 23, 3);
T('6.9580783101209078140E-48581', '-4.85801575106877669287286809338773712e+4', 36, 6);
T('9744128587282332519285270430948194876663392379.213638707444', '4.598874300644e+1', 13, 6);
T('2.766501232677186977E+737011644', '7.37011644441930868059942073866556713753e+8', 39, 1);
T('2.6900544536085441652753777658456769593839030E-446077922855484', '-4.4607792286e+14', 11, 3);
T('9.0732956736279418804179350529593096E+5862634', '5.86263495776506356e+6', 18, 1);
T('2.80882768445289586E+559928111119', '5.59928111119448525096985e+11', 24, 0);
T('7.3788369345555762835103181872689688744053494426218E+6730765357554464', '6.730765357554464867987912946224e+15', 31, 6);
T('2.959460383657043931925109388039896307947059E+217118802', '2.171188024712125307332e+8', 22, 5);
T('3.956189822575E+31473', '3.147359727712138e+4', 16, 6);
T('5.66115558664E+656037', '6.5603775290509084832386e+5', 24, 1);
T('2.22832507208902004302625237287424619121911957244944985098E+965119341084500', '9.651193410845003e+14', 16, 6);
T('4.924937211894443794211731987696726309241E+961', '9.6169240069804e+2', 14, 1);
T('6.74532192538022727744623280343816817441519585193095942574196E+274000599011', '2.74000599011829002681522e+11', 24, 2);
T('7.209E+208438', '2.0843885787502552356253390365498272e+5', 35, 1);
T('3.66697296539827857449270491425623117403827284683586725756528E-2693946', '-2.6939454356922918e+6', 17, 1);
T('9.66672E+117', '1.1798527913928017009e+2', 20, 0);
T('6.35397593596472700403828628827329751167708023099200772E+42960', '4.296080304557e+4', 13, 6);
T('6.9268983421699860434226567468545468532202E-50369901213127', '-5.0369901213126159461e+13', 20, 1);
T('2.7752758404982212331606452073789068022122859E+572216430298383', '5.7221643029838344330615504524e+14', 29, 3);
T('5.9258659730795671523367757357164829426084718E-5779', '-5.8e+3', 2, 5);
T('8.651770318575700584685873853475430890180871856E+1831200086', '1.83120008693710498156002691964e+9', 30, 6);
T('7.811677E+59875', '6e+4', 2, 4);
T('8.069294827273051E+60413580', '6.0413580906835583544206068198867779449e+7', 38, 1);
T('96665.84467385029724052359044402479905118965902303', '4.9852730501952027669068e+0', 23, 4);
T('5.6731273082624732574896505617039E-747376', '-7.4737524617747050624329252258e+5', 29, 6);
T('3.74224118190321841992531573E+30710', '3.07105731317737022950403907165374789e+4', 36, 1);
T('1.880930049536958430407325630040606122564969559449375102711E+6994552', '6.9e+6', 2, 1);
T('2.6006760504974637046746E-584358746865379', '-5.843587468653785849e+14', 19, 2);
T('4.58411E+47', '4.8e+1', 2, 4);
T('4.8472940870263640617671667416887043990955652178E+722180', '7.221806854993693201e+5', 19, 5);
T('4.41132498237110029E+49926409', '4.992640964456905343733638300111372e+7', 34, 4);
T('5.955180538536509606243984685694900793228258492011E+249149478', '2.5e+8', 2, 5);
T('2.55444785662336E-338393366512546', '-3.3839336651254559270295804802e+14', 30, 1);
T('6.451901656123260006240045354922178833320449E+109909171528', '1.0990917152880968773898219e+11', 29, 3);
T('1.710514210188E-797', '-8e+2', 1, 3);
T('8.1009E-1730350', '-1.73e+6', 3, 4);
T('6.4931410787499275369834890711938163837E+89747838', '8.97478388124548390435534618704031653e+7', 36, 2);
T('6.3496571795452363841138351936963590345581E-6935067975204336', '-6.935068e+15', 8, 4);
T('1.913624275E+7985454456610', '7.99e+12', 3, 5);
T('4.7516451294602805754081622774048795977503526E+296', '2.966768439984562e+2', 16, 1);
T('7.2727487252E+78582919900076', '7.9e+13', 2, 5);
T('9.9865454795458494E+1089656', '1.089656999415284159183e+6', 23, 4);
T('4.2018E-11544', '-1.1543377e+4', 8, 0);
T('5973677.8938888646013555597779580024611356600086806925613', '6.776242e+0', 7, 5);
T('1.785067221240412565271613355740530371935437309566266992884E+9012', '9.012251654575218e+3', 16, 5);
T('6.77262870644E+6524865', '6.525e+6', 4, 5);
T('5.401E+511754', '5.117547324742e+5', 13, 5);
T('4.350575000774444710047916754464678E+6459269855', '6.45927e+9', 6, 0);
T('2.32195277540589382014822154598157053567762490148686198057E+608316438358', '6.08316438358365853383e+11', 21, 0);
T('3.572760520633713318131179974412938E+6806', '6.81e+3', 3, 4);
T('8.610880702359934210E-170943074757322', '-1.7094307475732106495242757e+14', 26, 0);
T('8.1124646679657343581775011534919850721271601470915952884E+2753677807', '2.7537e+9', 5, 0);
T('7.657060557417E+7004', '7.00488406208181354696172876236543438249e+3', 39, 1);
T('1.094879339057202065200575548271891233128089058656211E+5216487789997', '5e+12', 1, 1);
T('7.01458738335172723967235286302265082E-92570843', '-9.25708421539978702e+7', 18, 1);
T('2.25E+533', '5e+2', 1, 1);
T('4.628672919927535486155536E+4800249379', '4.8002493796654564929259595102215430412e+9', 38, 5);
T('1.9732236825240345467809524550476270818E+9940971', '9.94097e+6', 6, 4);
T('0.000855603314909656837', '-3.06772754148692485696222290491457355e+0', 36, 3);
T('8.4439743851E+7039', '7.0399265469072e+3', 15, 2);
T('1.965407355492395E+2641', '2.641293452577056282791097210449374e+3', 35, 3);
T('8.77139E+43903', '4.3903943068421358703475e+4', 23, 4);
T('5.6313680606869681980405411323367891136242806344419E+673496449331', '6.73496449331750613913329559541527910906e+11', 39, 0);
T('3.70306748317210360217571459282646861523E+114549656', '2e+8', 1, 2);
T('7.9114974323311922708214149955178938396453680456512556208E+337714', '3.37714898258691468596e+5', 21, 0);
T('4.5241008127108799713242E+92522989', '9.252298e+7', 7, 1);
T('6.8084805182416E+4122762480376', '4.122762480376833050199111848192603042e+12', 37, 1);
T('7.3147485894705860825228409814E+6295', '6.2958641994038609222771252895147509e+3', 35, 6);
T('6.46562047642498844954E+863581336896', '8.6358133689681061020849827277507e+11', 32, 1);
T('6.9164633640051450512951E+55676', '5.5676839884080855434e+4', 20, 5);
T('6.0917452602066E+92256', '9.22567847417340599791691820043e+4', 30, 2);
T('0.001510148291305447959465032592', '-2.82098040440647561863609e+0', 25, 2);
T('6.431896480622181048622277E-61873878791340', '-6.187387879133919166e+13', 19, 2);
T('6.6912701039557846323852298837E+6543285327637841', '6.5432853276378418255085612e+15', 26, 3);
T('4.630341805517258573405153915987E+84165036', '8.4165036665613051227654781093827e+7', 32, 5);
T('6.6767502E-769588258', '-7.695882571754348719005572207e+8', 28, 5);
T('5.3660664E+9937317733853', '1e+13', 1, 4);
T('7.1104058881899289022794101576230407E+2931553762', '2.93155376286e+9', 12, 2);
T('9.0851565025843092256354899724035225E-574', '-5.7304e+2', 5, 1);
T('8.3224026230079773841863189513325893044219334182578E+9379449140735', '9.37944914073592024e+12', 18, 1);
T('7.3148E+964538455935', '9.64e+11', 3, 3);
T('0.088925797553215699187518', '-1.050972231046232305698200949769295607e+0', 37, 4);
T('3.344526235079323928990625352E+118763', '1.18763524334606987858365877234611e+5', 33, 3);
T('5.25123229692563277522479E+17940635681', '1.79406356817202612304450305496852e+10', 33, 0);
T('3.760845196952513780E+979276087629549', '9.7927608763e+14', 12, 4);
T('3.558E+527', '5.2755120594375e+2', 14, 4);
T('9.6965442455388605748343160757809944360E-86', '-8.5013384e+1', 8, 3);
T('4.105569485528819786620782603033703933E+88797225395276', '8.879722539527661337340683150145e+13', 31, 4);
T('1.91555944621E+813', '8.132822956341370931533119992804509e+2', 35, 6);
T('9.68951676654401806E+253127258067', '3e+11', 1, 4);
T('8E+5', '5.903e+0', 4, 4);
T('1836.634244419306349744257939937833631670519823', '3.26402267e+0', 9, 1);
T('4397784391509474398016375655554633061123389089.8634817139642', '4.564323393355751008e+1', 19, 5);
T('9.58322571E+731476802160807', '7.31476802160807981511717e+14', 25, 4);
T('7.01201371678194158217581603456218E+6878052429', '6.87805243e+9', 10, 4);
T('3.041163573728602511700770124120098256116370007710598988E+411', '4.1148e+2', 5, 1);
T('1.967922198E+61733161', '6.1733161294007924559145088394728e+7', 32, 6);
T('425.6382600813202', '2.62904065921972255e+0', 18, 1);
T('8.0822478421743991E+68533', '6.853390753216395349522e+4', 22, 5);
T('2.1228162931375958562519008684361087507E+8090388', '8.09038832691241228719325e+6', 24, 6);
T('203110.992750698269353255', '5.30773342887884e+0', 15, 2);
T('7.48005636875895E+2937', '2.9378e+3', 5, 3);
T('4.16308890258537660817667952193346640552129139713E+86307216', '8.63072166194156853e+7', 18, 6);
T('1.837949274E+6774278101554978', '6.7742782e+15', 8, 0);
T('8.79134871951167023906325966695773979628115E+2294220087861', '2.294220087861944056e+12', 19, 6);
T('8.48392244778725902939519101308465866886622E+87', '8.792859668994212084008e+1', 22, 3);
T('3.277969751826558179529913334137335285368628126773876030E+870', '8.7051560494170689524582890328993518e+2', 35, 4);
T('9270.9466671234823512338', '3.967e+0', 4, 3);
T('2.05000850836E+7932', '7.93231175566355e+3', 15, 1);
T('2.8771E+457370240210', '4.573702e+11', 7, 3);
T('1.0401380741318923836486E+963745538', '9.6374553801709099396546639851e+8', 29, 3);
T('7.565084298622151223299800630215724758148082623284064089163E-7708241360680', '-7.7082413606791211862e+12', 20, 6);
T('2.202424317826404394525541194184509298850156534E+6682', '6.68234290099362661e+3', 18, 6);
T('2.301525704833612235599549077113939656987426316438237947E+352351588647043', '3.52351588647043362015829721e+14', 27, 6);
T('2.3E+69', '6.936172783601759287886777711225e+1', 31, 4);
T('0.0023724981953987595', '-2.624794109239e+0', 13, 4);
T('1.636856E+832', '8.32214010474673898960782798539167823293e+2', 39, 0);
T('6.023E-92998', '-9.29972e+4', 6, 4);
T('5.750066890974305701482238212778089E-213689', '-2.13688240327103e+5', 15, 6);
T('6E+620838161', '6.2083816177815126e+8', 17, 2);
T('4.1964793930094E+1235150489006', '1.2351504890066228850948328e+12', 26, 5);
T('5.65102392645855754045555512257227119E+747964', '7.5e+5', 2, 0);
T('3.747046938286996368687346559251063750074E+55104332582', '5.5e+10', 2, 4);
T('7.316024918931619975E+28', '2.886427517605e+1', 13, 2);
T('7.188182778879818939E-84858665754', '-8.48586658e+10', 9, 6);
T('6.46323461493736556247481975257051362291072091E+357481253', '3.58e+8', 3, 0);
T('7.2362803608381682631379135460041040392E+285046289079184', '2.8504628907918485951538472263279356188e+14', 38, 5);
T('8.82583049866E+5498885147', '5.4988851479457555825035e+9', 23, 6);
T('8.262733965223247826311588406300E+398526734255312', '3.9852673425532e+14', 14, 0);
T('7.9724498208761428598305797621108619E+9680', '9.680901591794446e+3', 16, 5);
T('5.358807684948694056397783740398961810436E+135', '1.3572906817151193724055824197500226e+2', 35, 5);
T('7.50452481987293059567804821632785100731441200223007722872E+2647', '2.647875323198293e+3', 16, 5);
T('1.861461E+9765741622802', '9.76574162280226985394162224667547e+12', 33, 2);
T('5.3024E+18854', '1.88547244724867392427181951867e+4', 31, 2);
T('3.83567154703630127817968E+800', '8.00583841410955099993108474050708348e+2', 36, 5);
T('6.058225248967488175416955447960471E+45', '4.578234541666356245010242759860926972e+1', 37, 5);
T('5.583839582E+116575', '1.1657574693293295805902330044e+5', 29, 4);
T('5.45305449487944883848104927757569550811171661855161528497E+95598', '9.55987366398378128398982292162333013618e+4', 39, 1);
T('7.2E-1565', '-1.5641426675035687315397687275093163e+3', 35, 3);
T('5.688412098470009264410177753102487670040610414E+588291', '5.8829175499105143628966275381434335459e+5', 38, 3);
T('4.98687953451750846362292968828642954842916767E-8976294073461431', '-8.97629407346143030217112268322195e+15', 33, 3);
T('6.4059724761943175459267148700508435280570604843E+9068767037', '9.07e+9', 3, 2);
T('1.2558188143253810752E+5309', '5.3090989269852492340203207e+3', 26, 0);
T('2.9500993033018210931127104257014011E+6087', '6.0874e+3', 5, 3);
T('6.3695895298144359051982808553323123578E+67347444222', '6.7347444222804111446357e+10', 23, 1);
T('1.6970240931142969870064278143954369E+5862362', '5.8623622296880081587565662032e+6', 29, 0);
T('7.269866317942465252993451469798183786315582691680988137666E+6170368171023', '6.17036817102386152642490116878e+12', 30, 0);
T('5.010931460057255056843380556922E+952799', '9.527997e+5', 8, 6);
T('8.133134838508903211104693919333E+981997020692', '9.8199702069291025798e+11', 20, 0);
T('1.70776601623E+84', '8.42325e+1', 6, 0);
T('11.60521553826555618167636122646191312', '1.06465321081607303039810006711404092473e+0', 39, 4);
T('4.190828079947720296599477701349354520240413371E+88722', '8.87226e+4', 6, 3);
T('2.1159289143262425E+9818509', '9.818509325501073e+6', 16, 5);
T('4.70706E+1342622659861', '1.342622659861672749734211174727e+12', 31, 2);
T('4.3897940E-37', '-3.6357e+1', 5, 2);
T('3.223190179078E-9459981404844', '-9.45998140484349171406889429071e+12', 30, 5);
T('7.63774540593993554693734475525176E-2338460665997443', '-2.338460665997e+15', 13, 6);
T('7.08395369461253774236501117501869481991E+75775709160114', '7.57e+13', 3, 3);
T('4.764349864880E+2714827071468', '2.714e+12', 4, 3);
T('4.673416448899800598981630284876539E-328423146423', '-3.2842314642233036552e+11', 20, 6);
T('7.826045736338822738638958732226685960362E-1412', '-1.41110645761835949762542371879e+3', 30, 0);
T('5.796700333799240103896E-28859', '-2.885823681e+4', 10, 1);
T('8.97096663631613993250462383164860567863227128721354276181812E+176', '1.7695283924150562685124197e+2', 26, 0);
T('7.8585954305551819623439174147023744645039746762452852218E+73629027', '7.362902789534493137419777269992467e+7', 34, 5);
T('3.4382907684711E-42584717', '-4.258471647e+7', 10, 3);
T('1.41699080539874712712879548325887844471678E+3194156', '3.194156151367032196972e+6', 22, 0);
T('7.331289659351565E+1696410', '1.6964108651803788e+6', 17, 6);
T('1.745022889562179361781933066447101432E+535599', '5.355992418011279974051832982044808e+5', 34, 6);
T('4.30739431731149846909077453595545769250098838827929287457735E+6256201941', '6.2562019416342146307581404214050605352e+9', 38, 6);
T('1.588554116485404477492730355848E+3496', '3.4962010020143099479653792462688377e+3', 35, 3);
T('9.900888E-106498', '-1.064970043258522504e+5', 19, 1);
T('8.83580012650210959E+73456', '7.345694624589e+4', 13, 0);
T('8.8949043525769342851448782098279774889770917544263726E-82775565', '-8.2775e+7', 5, 2);
T('3.6224442E-141', '-1.4045e+2', 5, 0);
T('8.59405672549749313626581182770673689820022E-32033035', '-3.20331e+7', 6, 3);
T('9.51074073247087480768657837136488292943959703869E+275930276482999', '2.7593027648299997821435e+14', 23, 2);
T('2.54065063418647762504692974337669E+406474715003143', '4.064747150031434e+14', 17, 1);
T('9489953385.25328239339198556294098175754101987164777', '9.977264079173657754167815e+0', 25, 0);
T('4.5232942439068434456152833847455813722535773E-4462', '-4.46e+3', 3, 1);
T('7.0802826525E+787135580', '7.87135580850050595538747730277159237612e+8', 39, 4);
T('5.8216966113439E+223611', '2.2361176504956911165649331380712912243e+5', 38, 4);
T('3.33244818745948041153812422494096916019823856474870E+517782641176005', '5.1778264117600552276340578e+14', 26, 5);
T('2.05912361945417878137840483E+5552624271309', '5.552624e+12', 7, 1);
T('6.84742824413083454475067895412838639947431E-39838897', '-3.9838896164472510127860873720016710505e+7', 38, 2);
T('3.95807149459035557997365582562827797684887001622411167547181E+1549', '1.54959748363e+3', 12, 5);
T('2.0195949695778122120385695521227579706871529732687E-55200', '-5.5199694735719719133330807334889920748e+4', 38, 4);
T('7.8171596648329304689657474893269001820416900818139E+131702572699', '1.31702572699893048982476210061446323262e+11', 39, 2);
T('5.0668399219162114869148E+3655', '3.655704737183720975024589242605e+3', 31, 0);
T('4.75555399593131396464117509556003E+610', '6.10677201117143314e+2', 19, 4);
T('4.478467972936253610790510078714E+1024', '1.024651129472772477335e+3', 23, 3);
T('1.4408051213207621033E+529220956779', '5.292209567791586053e+11', 19, 0);
T('7.10903333703321992919455115881016884828773E+216193', '2.161938518105508e+5', 16, 5);
T('3.01777E+59773', '5.97734796861368520217703676e+4', 27, 3);
T('8.207881805736931035390756744751707691802017739454540300E-2164854877141559', '-2.16485487714155e+15', 15, 2);
T('9.633610519523911273743199583415128174038760209192103E-124', '-1.23016210915904169742864e+2', 24, 6);
T('4.69414682782169969201733241661926387578671440642216E-7082634132334465', '-7.08263413233446432844333026e+15', 27, 1);
T('3.739788296386425205173905702442336339893085E+3772780166993', '3.772780167e+12', 11, 4);
T('2.55408368428247917203004684693105826775753E+390699550133', '3.90699550133407235122773402e+11', 27, 6);
T('7.251474452851442402672495958892746452E+49940264985545', '4.9940264985545860426321279e+13', 26, 5);
T('1.721182063637637944851802912796631080152254327700488E+39830', '3.98302358268116704603889e+4', 24, 5);
T('6.0160E+6432654', '6.432654779e+6', 10, 4);
T('6.1412E+58567968', '5.856796878825e+7', 13, 4);
T('4.6942768850847549904995671905357285207275829424268523550395E+813', '8.136716e+2', 7, 2);
T('4E-20586837', '-2e+7', 1, 5);
T('9.581407894052410E+716956335992', '7.169563359929814293290882793134e+11', 31, 0);
T('9.02517435211003151096977993840249057659E+49790830466082', '4.97908304660829554556005420051e+13', 30, 0);
T('6.35042592535315544207236947351E+38', '3.8802802854556101872830211083071e+1', 32, 4);
T('7.3857993596821934361411966047009506536956121E+769171391', '7.692e+8', 4, 6);
T('8.62E-5441684634440', '-5.441684634439064492735e+12', 22, 0);
T('3.38129500769046530005909717304004367640216011150E-19802852', '-1.980285147091693671045805032352e+7', 31, 5);
T('6.529755524524004983762782691926155E+41790', '4.17908148969214990010338098e+4', 28, 6);
T('6.2356159650232275E+435456077183', '4.35456077183794879360300148491e+11', 30, 0);
T('1.06610584819233041984469468751207423544105865915E-54045758', '-5.404575797219967e+7', 16, 6);
T('4.0645298587882401075248650399370490791E+1661984', '1.66198460901031830839250688097659180396e+6', 39, 1);
T('5.293607557105180254720699965156017448949177246642E+70986909', '7.098690972375174163076659557650674483e+7', 37, 2);
T('3.3597230648953198398658762540008674386627018103381E+556809183042954', '5.5680918e+14', 8, 4);
T('4.5827E-3063727', '-3.06372634e+6', 9, 5);
T('6.827387820647755116E+91567807', '9.15678078342545730704445336689514619209e+7', 39, 3);
T('2.107416729706044661767557E-507964854044716', '-5.08e+14', 3, 3);
T('5.50927251577102E+865656592439', '8.656565e+11', 7, 3);
T('3.98021181734497757342512733248537061996368597496710547724438E+36994589', '3.699458959990618480139602631124e+7', 31, 5);
T('5.301444115538624029E-123333622739', '-1.23333622738275605812289583781e+11', 30, 0);
T('7.76903608002529822525212598E-5393243350993', '-5.3932433509922e+12', 14, 0);
T('8.99577590795471215209062998374857929772E+27728726', '2.7728726954e+7', 11, 5);
T('9.2800343E+116', '1.16967549581420715521021089418e+2', 30, 3);
T('3.977785722122324570544976154849E+2026608816324425', '2.0266088163244255997e+15', 20, 2);
T('5.076612022561327891899414337745979097225486208822555E+1487002218', '1.4870022187055739739424853775232485e+9', 36, 6);
T('6.0380E+10771969', '1.0771969780893108687079e+7', 24, 0);
T('4.136300926E+4521437761', '4.5214377616166121272201e+9', 23, 5);
T('9.22197478861493479118165328708963109905458469027359887185E+9801078721222', '9.8010787212229648239e+12', 20, 1);
T('9.4956474346866285754042480762819121552440915291460650971217E+71762533504', '7.176253350497752458126112751125707e+10', 34, 1);
T('1.2644471156926304326001813E+84', '8.41019006701033912892e+1', 21, 3);
T('9.506977552139186104379591692476780E-76004', '-7.600302195753154429093352099592805779e+4', 37, 1);
T('2.957532705030717197E+99157', '9.915747092955584801104179643091e+4', 31, 6);
T('7.09E-856335', '-8e+5', 1, 1);
T('3.07871052E-960121094972360', '-9.60121094972359511631144314377046968e+14', 36, 2);
T('6.8E+958593705', '9.58593705832508912706236318968e+8', 30, 5);
T('5.6609E-810185', '-8.1018e+5', 5, 6);
T('3.6558695839138249990426146888447712E-845885711328867', '-8.45885711328866437009e+14', 21, 5);
T('4.3751179237797712870357135036405450959980035923344E+88017014', '8.8017014641e+7', 11, 0);
T('3.126326E+7', '7.5e+0', 3, 2);
T('5.5446354250391559981621639541476945764347487E+99', '9.9743872995372639427954942e+1', 27, 5);
T('6.83359216868393351813673053376398E-768516737', '-7.685167362e+8', 10, 3);
T('3.5756036122224666277275933636622914974272944179692E-33164602799132', '-3.3164602799131446650632651919e+13', 29, 4);
T('6.3647380108303890323974286224992387800147568486084145918E+92960', '9.29608037805316672236175396822532819958e+4', 39, 4);
T('3.655327513874682496408952E+241392', '2.41392562926295410475695688e+5', 27, 3);
T('3.50605948150100548853692707939376333427406113641347093729713E+82773535153', '8.277353515354481927977504146210064151e+10', 37, 0);
T('7.310307960686719E+1014647837216539', '1.014647837216539863935672827860541609e+15', 38, 1);
T('8.9958342461392085028378371339449567463900820E+9042', '9.04296e+3', 6, 0);
T('7.9074217927308678583E-8055', '-8.05410196509472092e+3', 18, 1);
T('4.71498107545049919E+3918717021260325', '3.91871702126032567347995394e+15', 27, 1);
T('3.95444611001117195409E+86', '8.65970857e+1', 9, 5);
T('3.18843306841991860797879308596248315871925802644766577402711E+45977468583', '4.597746858350357730471013599925e+10', 31, 3);
T('6.22570422125935111934774E+4254868031441062', '4.2548680314410627942e+15', 20, 5);
T('16.03204924004841325542492869198973017652', '1.204989e+0', 8, 3);
T('1.3654185685412343953580259247722E-531996253', '-5.31996253e+8', 9, 6);
T('4.71252353423253553966540276306417102E+953823831', '9.53e+8', 3, 3);
T('1.278141210944641028302392491356322105E+23751988941935', '2.375198e+13', 7, 1);
T('2.953816209213038450561378564E+63693096648', '6.369309664847e+10', 13, 3);
T('9.83165012596577211760566749445836512198588929716039287E+84414627', '8.4414628e+7', 9, 2);
T('4.68956719459375555E+6671031', '6.67103167113276304063696287334162702e+6', 36, 2);
T('8.5619E+46140632620', '4.61406326209325701511e+10', 21, 6);
T('6.7286418039128390E+53588775321541', '5.358878e+13', 7, 4);
T('9.21845775502E+309965433290', '3.0996543329096465826980535055070799804e+11', 38, 6);
T('1.3869745783736495958786116744238903364E+825322', '8.25e+5', 3, 3);
T('1.825E-2472008736902690', '-2.47200873690268973873713120751e+15', 30, 4);
T('5.9219317E+3999610292171', '3.999610292171772463394190706e+12', 28, 6);
T('5.72750456430116440072740529290526066460700960580E+57751419', '5.775141975796544395484753985352e+7', 31, 4);
T('2.68091712962E-815', '-8.1457171661037557e+2', 17, 5);
T('1.38094E+2063', '2e+3', 1, 4);
T('8.5209845773496385982442318897466408E+48727127237', '4.9e+10', 2, 5);
T('2.302011E+6115146295', '6.1151462953621073945448099e+9', 26, 3);
T('2.89175443197729017916360237450799650414E-3096072526420', '-3.096072526419538839e+12', 19, 0);
T('9202.20225997385641312038794860942786773', '3.96389177461e+0', 12, 3);
T('0.000007310305777806927856977926355044917154612541', '-5.136064456853788246578869978739617164e+0', 37, 1);
T('3.92871079665090398794493191930758E-213143923295', '-2.13143923294e+11', 12, 1);
T('4.938356900829494427605602164551241E+430201502312221', '4.30201502312222e+14', 15, 4);
T('6.491874137133116252625941441690426276235236284508843505192E-97563443', '-9.756344219e+7', 10, 0);
T('6.15092047610497936007038744E+8208499133204', '8.2084991332047889401e+12', 20, 4);
T('286.92707068747734494438523412969996882', '2.46e+0', 3, 2);
T('7.60950578077754732903891601421880E-83599', '-8.35981186435487026309413e+4', 24, 3);
T('6.977587013708000E+6917', '6.917843705261045671e+3', 19, 4);
T('9.63689981460249470383307333E-98768150428115', '-9.87681504281140160626559e+13', 24, 2);
T('1.738318789984661940353053893061128387825642031515449517E+5964494192', '5.9644941922401e+9', 14, 4);
T('8.38787701253582907E+463', '4.6392365205398588e+2', 17, 1);
T('9.802636321113883267418E+484162298747106', '4.8416229874710699134e+14', 20, 1);
T('4.492325834E+59858434', '5.985843465247124865269261063433e+7', 31, 4);
T('9.336327683727813389043806701E+25573134966275', '2.55731349662759701e+13', 18, 3);
T('5.7690E+6930821612762', '6.930821612762761100538958142296e+12', 31, 1);
T('7.234860786329978712579251553140673876E+4617', '4.61785943017881229510597105156e+3', 30, 5);
T('2.31892719704128397385272539633537327546738574387107382E-343156242878', '-3.4315624287763471289e+11', 20, 3);
T('2223999943.89810311445890834443656215387', '9.3471347719546491108598298398282171e+0', 35, 3);
T('3.7327171497158E-7', '-6.427974917915026222e+0', 19, 5);
T('2.793677314157573549808840E+532', '5.3244617624115755788973705e+2', 26, 6);
T('7.640898943682386533902335E+536009329594188', '5.36e+14', 4, 4);
T('8.9074250430447141026785391328342688479479051E+21963922635578', '2.1963922635578949e+13', 17, 3);
T('5.5762216618089304820E-6976208', '-6.976207253659970816237e+6', 22, 5);
T('1.91357401642E+49961236827', '4.99612368272818452652545816872375e+10', 33, 2);
T('5.957297990106291252829815394260394318083353E-26245957645478', '-2.6245957645477e+13', 14, 1);
T('8.01844860599820804155768000879876725329864650214532E+436946856', '4.36946856904090349951357241211271e+8', 33, 2);
T('5.5574947893333547365232067522673911E+7059', '7.05974487906417987536846332910957964e+3', 36, 5);
T('9.552816484569040E+6270', '6.2709801314347641e+3', 17, 0);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,159 @@
var count = (function minMax(Decimal) {
var start = +new Date(),
log,
error,
u,
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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(min, max, arr) {
assert(true, new Decimal(min).eq(Decimal.min(arr)));
assert(true, new Decimal(max).eq(Decimal.max(arr)));
}
log('\n Testing min and max...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: false
});
assert(false, Decimal.min(0, 0, 0).isNaN());
assert(true, Decimal.min(u, null, NaN).isNaN());
assert(true, Decimal.min(-2, 0, -1, u).isNaN());
assert(true, Decimal.max(-2, 0, -1, u).isNaN());
assert(true, Decimal.min(null, -2, 0, -1).isNaN());
assert(true, Decimal.max(null, -2, 0, -1).isNaN());
assert(true, Decimal.min(NaN, -2, 0, -1).isNaN());
assert(true, Decimal.max(NaN, -2, 0, -1).isNaN());
assert(true, Decimal.min(-2, 0, -1, new Decimal(NaN)).isNaN());
assert(true, Decimal.max(-2, 0, -1, new Decimal(NaN)).isNaN());
assert(false, Decimal.min(-2, 0, -1).isNaN());
assert(false, Decimal.max(-2, 0, -1).isNaN());
assert(false, Decimal.min(-2, 0, -1, Infinity).isNaN());
assert(false, Decimal.max(-2, 0, -1, -Infinity).isNaN());
assert(false, Decimal.min(-2, 0, -1, Infinity).isNaN());
assert(false, Decimal.max(-2, 0, -1, Infinity).isNaN());
assert(false, Decimal.min(-2, -Infinity, 0, -1, Infinity).isNaN());
assert(true, Decimal.max(Infinity, -2, 'hi', 0, -1, -Infinity).isNaN());
assert(true, Decimal.min(null, Infinity, -2, 0, -1, -Infinity).isNaN());
assert(true, Decimal.max(Infinity, -2, NaN, 0, -1, -Infinity, u).isNaN());
assert(true, new Decimal(-Infinity).eq(Decimal.min(-Infinity, -2, 0, -1, Infinity)));
assert(true, new Decimal(-Infinity).eq(Decimal.min(Infinity, -2, 0, -1, -Infinity)));
assert(true, new Decimal(Infinity).eq(Decimal.max(Infinity, -2, 0, -1, -Infinity)));
assert(true, new Decimal(Infinity).eq(Decimal.max(-Infinity, -2, 0, new Decimal(Infinity), -1)));
assert(true, new Decimal(-2).eq(Decimal.min(-2, 0, -1)));
assert(true, new Decimal(0).eq(Decimal.max(-2, 0, -1)));
assert(true, new Decimal(-2).eq(Decimal.min(-2, -1, 0)));
assert(true, new Decimal(0).eq(Decimal.max(-2, -1, 0)));
assert(true, new Decimal(-2).eq(Decimal.min(0, -2, -1)));
assert(true, new Decimal(0).eq(Decimal.max(0, -2, -1)));
assert(true, new Decimal(-2).eq(Decimal.min(0, -1, -2)));
assert(true, new Decimal(0).eq(Decimal.max(0, -1, -2)));
assert(true, new Decimal(-2).eq(Decimal.min(-1, -2, 0)));
assert(true, new Decimal(0).eq(Decimal.max(-1, -2, 0)));
assert(true, new Decimal(-2).eq(Decimal.min(-1, 0, -2)));
assert(true, new Decimal(-1).eq(Decimal.min(-1, 0, 1)));
assert(true, new Decimal(1).eq(Decimal.max(-1, 0, 1)));
assert(true, new Decimal(-1).eq(Decimal.min(-1, 1, 0)));
assert(true, new Decimal(1).eq(Decimal.max(-1, 1, 0)));
assert(true, new Decimal(-1).eq(Decimal.min(0, -1, 1)));
assert(true, new Decimal(1).eq(Decimal.max(0, -1, 1)));
assert(true, new Decimal(-1).eq(Decimal.min(0, 1, -1)));
assert(true, new Decimal(1).eq(Decimal.max(0, 1, -1)));
assert(true, new Decimal(-1).eq(Decimal.min(1, -1, 0)));
assert(true, new Decimal(1).eq(Decimal.max(1, -1, 0)));
assert(true, new Decimal(-1).eq(Decimal.min(1, 0, -1)));
assert(true, new Decimal(-1).eq(Decimal.min('-1', 0, new Decimal(1))));
assert(true, new Decimal(1).eq(Decimal.max('-1', 0, new Decimal(1))));
assert(true, new Decimal(-1).eq(Decimal.min('-1', new Decimal(1), 0)));
assert(true, new Decimal(1).eq(Decimal.max('-1', new Decimal(1), 0)));
assert(true, new Decimal(-1).eq(Decimal.min(0, '-1', new Decimal(1))));
assert(true, new Decimal(1).eq(Decimal.max(0, '-1', new Decimal(1))));
assert(true, new Decimal(-1).eq(Decimal.min(0, new Decimal(1), '-1')));
assert(true, new Decimal(1).eq(Decimal.max(0, new Decimal(1), '-1')));
assert(true, new Decimal(-1).eq(Decimal.min(new Decimal(1), '-1', 0)));
assert(true, new Decimal(1).eq(Decimal.max(new Decimal(1), '-1', 0)));
assert(true, new Decimal(-1).eq(Decimal.min(new Decimal(1), 0, '-1')));
assert(true, new Decimal(0).eq(Decimal.min(0, 1, 2)));
assert(true, new Decimal(2).eq(Decimal.max(0, 1, 2)));
assert(true, new Decimal(0).eq(Decimal.min(0, 2, 1)));
assert(true, new Decimal(2).eq(Decimal.max(0, 2, 1)));
assert(true, new Decimal(0).eq(Decimal.min(1, 0, 2)));
assert(true, new Decimal(2).eq(Decimal.max(1, 0, 2)));
assert(true, new Decimal(0).eq(Decimal.min(1, 2, 0)));
assert(true, new Decimal(2).eq(Decimal.max(1, 2, 0)));
assert(true, new Decimal(0).eq(Decimal.min(2, 1, 0)));
assert(true, new Decimal(2).eq(Decimal.max(2, 1, 0)));
assert(true, new Decimal(0).eq(Decimal.min(2, 0, 1)));
assert(true, new Decimal(2).eq(Decimal.max(2, 0, 1)));
T(-2, 0, [-2, -1, 0]);
T(-2, 0, [-2, 0, -1]);
T(-2, 0, [-1, -2, 0]);
T(-2, 0, [-1, 0, -2]);
T(-2, 0, [0, -2, -1]);
T(-2, 0, [0, -1, -2]);
T(-1, 1, [-1, 0, 1]);
T(-1, 1, [-1, 1, 0]);
T(-1, 1, [0, -1, 1]);
T(-1, 1, [0, 1, -1]);
T(-1, 1, [1, -1, 0]);
T(-1, 1, [1, 0, -1]);
T(0, 2, [0, 1, 2]);
T(0, 2, [0, 2, 1]);
T(0, 2, [1, 0, 2]);
T(0, 2, [1, 2, 0]);
T(0, 2, [2, 1, 0]);
T(0, 2, [2, 0, 1]);
T(-0.000001, 999.001, [2, -0, '1e-9000000000000000', 324.32423423, -0.000001, '999.001', 10]);
T('-9.99999e+9000000000000000', Infinity, [10, '-9.99999e+9000000000000000', new Decimal(Infinity), '9.99999e+9000000000000000', 0]);
T('-9.999999e+9000000000000000', '1.01e+9000000000000000', ['-9.99998e+9000000000000000', '-9.999999e+9000000000000000', '9e+8999999999999999', '1.01e+9000000000000000', 1e+300]);
T(1, Infinity, [1, '1e+9000000000000001', 1e200]);
T(-Infinity, 1, [1, '-1e+9000000000000001', -1e200]);
T(0, 1, [1, '1e-9000000000000001', 1e-200]);
T(0, 1, [1, '-1e-9000000000000001', 1e-200]);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,471 @@
var count = (function neg(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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), String(new Decimal(value).neg()));
}
function isMinusZero(n) {
return n.toString() === '0' && n.s == -1;
}
log('\n Testing neg...');
Decimal.config({
precision: 20,
rounding: 4,
errors: true,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
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('-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');
Decimal.toExpNeg = Decimal.toExpPos = 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('-9.99e+9000000000000000', '9.99e+9000000000000000');
T('9.99e+9000000000000000', '-9.99e+9000000000000000');
T('-Infinity', '1e+9000000000000001');
T('Infinity', '-1e+9000000000000001');
T('-1e-9000000000000000', '1e-9000000000000000');
T('1e-9000000000000000', '-1e-9000000000000000');
T('0e+0', '-1e-9000000000000001');
T('-Infinity', Infinity);
T('-Infinity', 'Infinity');
T('Infinity', -Infinity);
T('Infinity', '-Infinity');
T('NaN', NaN);
T('NaN', 'NaN');
Decimal.toExpNeg = -9e15;
Decimal.toExpPos = 9e15;
assert(-1, new Decimal(2).neg().s);
assert(1, new Decimal(-2).neg().s);
assert(null, new Decimal(NaN).neg().s);
assert(null, new Decimal('-NaN').neg().s);
assert(-1, new Decimal(Infinity).neg().s);
assert(1, new Decimal('-Infinity').neg().s);
assert(false, isMinusZero(new Decimal(1).neg()));
assert(true, isMinusZero(new Decimal(0).neg()));
assert(true, isMinusZero(new Decimal(0).neg()));
assert(true, isMinusZero(new Decimal('0.00000').neg()));
assert(true, isMinusZero(new Decimal('+0.0').neg()));
assert(false, isMinusZero(new Decimal(-0).neg()));
assert(false, isMinusZero(new Decimal('-0').neg()));
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,489 @@
/*
For help:
$ node bigtime -h
Usage example:
Compare the time taken by the Decimal 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 Decimal results match the BigDecimal results.
$ node bigtime plus 10000 40
*/
var arg, i, j, max, mc, method, methodIndex, precision, rounding, reps, start,
timesEqual, xs, ys, prevRss, prevHeapUsed, prevHeapTotal, showMemory,
bdM, bdT, bdR, bdRs, dM, dT, dR, dRs,
args = process.argv.splice(2),
bigdecimal = require('./lib/bigdecimal_GWT/bigdecimal'),
BigDecimal = bigdecimal.BigDecimal,
MathContext = bigdecimal.MathContext,
Decimal = require('../../decimal'),
bdMs = ['add', 'subtract', 'multiply', 'divide', 'remainder', 'compareTo', 'pow', 'negate', 'abs'],
dMs1 = ['plus', 'minus', 'times', 'dividedBy', 'modulo', 'comparedTo', 'toPower', 'negated', 'abs'],
dMs2 = ['', '', '', 'div', 'mod', 'cmp', '', 'neg', ''],
Ms = [bdMs, dMs1, dMs2],
allMs = [].concat.apply([], Ms),
bdTotal = 0,
dTotal = 0,
BD = {},
BN = {},
modes = ['UP', 'DOWN', 'CEILING', 'FLOOR', 'HALF_UP', 'HALF_DOWN', 'HALF_EVEN'],
ALWAYS_SHOW_MEMORY = false,
DEFAULT_MAX_DIGITS = 20,
DEFAULT_POW_MAX_DIGITS = 20,
DEFAULT_REPS = 1e4,
DEFAULT_POW_REPS = 1e2,
DEFAULT_PRECISION = 20,
MAX_POWER = 50,
MAX_RANDOM_EXPONENT = 100,
getRandom = function (maxDigits) {
var z,
i = 0,
// number of digits - 1
n = Math.random() * ( maxDigits || 1 ) | 0,
// No numbers between 0 and 1 or BigDecimal remainder operation may fail with 'Division impossible' error.
r = ( ( bdM == 'remainder' ? Math.random() * 9 + 1 : Math.random() * 10 ) | 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 (d, bd) {
var r;
if (Math.abs(d - bd) > 2) {
r = ((d < bd)
? 'Decimal was ' + (d ? parseFloat((bd / d).toFixed(1)) : bd)
: 'BigDecimal was ' + (bd ? parseFloat((d / bd).toFixed(1)) : d)) + ' 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;
}
},
toKB = function (m) { return parseFloat((m / 1024).toFixed(1)) },
getMemoryTotals = function (obj) {
return '\trss: ' + toKB(obj.rss) + '\thU: ' + toKB(obj.hU) + '\thT: ' + toKB(obj.hT);
};
arg = args[0];
if ( typeof arg != 'undefined' && !isFinite(arg) &&
allMs.indexOf(arg) == -1 && !/^-*m$/i.test(arg)) {
console.log(
'\n node bigtime [METHOD] [METHOD CALLS [MAX DIGITS [precision]]]\n' +
'\n METHOD: The method to be timed and compared with the' +
'\n \t corresponding method from BigDecimal or Decimal\n' +
'\n BigDecimal: add subtract multiply divide remainder compareTo pow' +
'\n\t\tnegate abs\n\n Decimal: 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 ' +
'precision: The maximum number of significant digits of a result' +
'\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 precision: ' + DEFAULT_PRECISION + '\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 {
// INITALISE
Decimal.config({
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
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 (precision == null) precision = arg <= 1e6 ? arg : DEFAULT_PRECISION;
} 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++) {}
dM = methodIndex == -1
? dMs1[methodIndex = Math.floor(Math.random() * bdMs.length)]
: (Ms[i][0] == 'add' ? dMs1 : 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 (precision == null) precision = DEFAULT_PRECISION;
/*
BigDecimal remainder needs precision to be >= number of digits of operands:
"Division impossible: This occurs and signals invalid-operation if the integer result of a
divide-integer or remainder operation had too many digits (would be longer than precision)."
*/
if ( bdM == 'remainder' && max > precision ) {
max = precision;
}
// Get random rounding mode.
rounding = Math.floor(Math.random() * 7);
xs = [reps], ys = [reps], bdRs = [reps], dRs = [reps];
BD.rss = BD.hU = BD.hT = BN.rss = BN.hU = BN.hT = 0;
showMemory = showMemory || ALWAYS_SHOW_MEMORY;
console.log('\n Decimal %s vs BigDecimal %s\n' +
'\n Method calls: %d\n\n Random operands: %d', dM, bdM, reps,
bdM == 'abs' || bdM == 'negate' || bdM == 'abs' ? reps : reps * 2);
console.log(' Max. digits of operands: %d', max);
console.log('\n Precision: %d\n Rounding mode: %d', precision, rounding);
process.stdout.write('\n Testing started');
// TEST
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
/*
// Rounding modes 0 UP, 1 DOWN, 2 CEILING, 3 FLOOR, 4 HALF_UP, 5 HALF_DOWN, 6 HALF_EVEN
new BigDecimal('100').divide( new BigDecimal('3') ); // Exception, needs a rounding mode.
new BigDecimal('100').divide( new BigDecimal('3'), 0 ).toString(); // 34
var x = new BigDecimal('5');
var y = new BigDecimal('3');
// MathContext objects need to be initialised with a string!?
var mc = new MathContext('precision=5 roundingMode=HALF_UP');
console.log( x.divide( y, mc ).toString() ); // '1.6667'
// UNLIMITED precision=0 roundingMode=HALF_UP
// DECIMAL32 precision=7 roundingMode=HALF_EVEN
// DECIMAL64 precision=16 roundingMode=HALF_EVEN
// DECIMAL128 precision=34 roundingMode=HALF_EVEN
// Note that these are functions!
console.log( x.divide( y, MathContext.DECIMAL64() ).toString() ); // '1.666666666666667'
// Set scale (i.e. decimal places) and rounding mode.
console.log( x.divide( y, 2, 4 ).toString() ); // '1.67'
// DOWN is a function, ROUND_DOWN is not!
console.log( x.divide( y, 6, RoundingMode.DOWN() ).toString() ); // '1.666666'
console.log( x.divide( y, 6, BigDecimal.ROUND_DOWN ).toString() ); // '1.666666'
*/
mc = new MathContext('precision=' + precision + ' roundingMode=' + modes[rounding] );
if (bdM == 'pow') {
start = +new Date();
for (i = 0; i < j; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](ys[i], mc);
}
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]), mc);
}
bdT = +new Date() - start;
}
getMemory(BD);
/*
// Debug: insert the following into the for-loop above.
try {
bdRs[i] = new BigDecimal(xs[i])[bdM](new BigDecimal(ys[i]), mc);
} catch(e) {
console.log(e);
console.log('\n Error. Operation number ' + i);
console.log('\n x: %s\n y: %s', xs[i], ys[i]);
console.log('\n precision: %d\n rounding: %d', precision, rounding);
bdRs[i] = { toPlainString: function () { return 'failed' } };
}
*/
// BIGNUMBER
Decimal.config({ precision: precision, rounding: rounding });
if (bdM == 'abs' || bdM == 'negate') {
start = +new Date();
for (i = 0; i < j; i++) {
dRs[i] = new Decimal(xs[i])[dM]();
}
dT = +new Date() - start;
} else {
start = +new Date();
for (i = 0; i < j; i++) {
dRs[i] = new Decimal(xs[i])[dM](ys[i]);
}
dT = +new Date() - start;
}
getMemory(BN);
// CHECK FOR MISMATCHES
for (i = 0; i < j; i++) {
dR = dRs[i].toString();
bdR = bdRs[i].toPlainString();
// Strip any trailing zeros from non-integer BigDecimals
if (bdR.indexOf('.') != -1) {
bdR = bdR.replace(/\.?0+$/, '');
}
if (bdR !== dR) {
console.log(
'\n breaking on first mismatch (result number %d):' +
'\n\n BigDecimal: %s\n Decimal: %s', i, bdR, dR
);
console.log('\n x: %s\n y: %s', xs[i], ys[i]);
console.log('\n precision: %d\n rounding: %d', precision, rounding);
break outer;
}
}
bdTotal += bdT;
dTotal += dT;
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\tDecimal ' + getMemoryTotals(BN)
);
}
console.log(
'\n Time taken:' + '\n\tBigDecimal ' + (bdTotal || '<1') + ' ms' +
'\n\tDecimal ' + ( dTotal || '<1') + ' ms\n\n ' +
getFastest(dTotal, bdTotal) + '\n'
);
}
}
/*
BigDecimal notes:
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
*/

@ -0,0 +1,771 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<meta name="Author" content="M Mclaughlin">
<title>Testing Decimal against BigDecimal</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;}
#sd, #r, #digits, #reps {margin-left: 0.8em;}
#bigint {font-style: italic; display: none;}
#gwt, #icu4j, #bd, #bigint {margin-left: 1.5em;}
#counter {font-size: 2em; background-color: rgb(235, 235, 235);}
#time {text-align: center;}
#results {margin: 0 1.4em;}
</style>
<script src='../../decimal.js'></script>
<script src='./lib/bigdecimal_GWT/bigdecimal.js'></script>
</head>
<body>
<h1>Testing Decimal 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='context'>
<span>Precision:<input type='text' id='sd' 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'>Decimal</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,
isFixed, isIntOnly, maxDigits, mc, precision, rounding, calcTimeout,
counterTimeout, script, isGWT, BigDecimal_GWT, BigDecimal_ICU4J,
bdM, bdTotal, dM, dTotal,
bdMs = ['add', 'subtract', 'multiply', 'divide', 'remainder', 'compareTo', 'abs', 'negate', 'pow'],
dMs = ['plus', 'minus', 'times', 'div', 'mod', 'cmp', 'abs', 'neg', 'pow'],
modes = ['UP', 'DOWN', 'CEILING', 'FLOOR', 'HALF_UP', 'HALF_DOWN', 'HALF_EVEN'],
lastRounding = 4,
pause = false,
up = true,
timingVisible = false,
showAll = false,
// EDIT DEFAULTS HERE
DEFAULT_REPS = 10000,
DEFAULT_DIGITS = 20,
DEFAULT_PRECISION = 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'),
$SD = $('sd'),
$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,
// No numbers between 0 and 1 or BigDecimal remainder operation may fail with 'Division impossible' error.
r = ( ( bdM == 'remainder' ? Math.random() * 9 + 1 : Math.random() * 10 ) | 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, dS,
sp = '',
r = dTotal < bdTotal
? (dTotal ? bdTotal / dTotal : bdTotal)
: (bdTotal ? dTotal / bdTotal : dTotal);
bdS = 'BigDecimal: ' + (bdTotal || '<1');
dS = 'Decimal: ' + ( dTotal || '<1');
for ( i = bdS.length - dS.length; i-- > 0; sp += '&nbsp;') {}
dS = 'Decimal: ' + sp + (dTotal || '<1');
$TIME.innerHTML = 'No mismatches<div>' + bdS + ' ms<br>' + dS + ' ms</div>' + (
(r = parseFloat(r.toFixed(1))) > 1
? (dTotal < bdTotal ? 'Decimal' : 'BigDecimal') + ' 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) {
dM = dMs[$INPUTS[i].id];
bdM = bdMs[$INPUTS[i].id];
break;
}
}
isFixed = $FIX.checked;
isIntOnly = $INT.checked;
showAll = $SHOW.checked;
isGWT = $GWT.checked;
precision = isFinite(i = +$SD.value) ? i : DEFAULT_PRECISION;
/*
// BigDecimal_ICU4J rounds operands to precision before performing the calculation.
if (precision < maxDigits && !isGWT) {
precision = maxDigits + 1;
}
*/
$SD.value = precision
rounding = $R.selectedIndex;
// Set precision and rounding
Decimal.config({ precision: precision, rounding: rounding });
if (isGWT) {
BigDecimal = isIntOnly ? BigInteger : BigDecimal_GWT;
mc = new MathContext_GWT('precision=' + precision + ' roundingMode=' + modes[rounding]);
} else {
BigDecimal = BigDecimal_ICU4J;
mc = new MathContext_ICU4J(precision, MathContext_ICU4J.PLAIN, false, rounding);
}
prevCycleReps = cycleLimit = completedReps = bdTotal = dTotal = 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, dT, bdR, dR,
xs = [cycleReps],
ys = [cycleReps],
bdRs = [cycleReps],
dRs = [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
/*
// BigDecimalICU4J
// Rounds operands to precision before performing a calculation.
// Rounding to precision of add, subtract and pow seems unfathomable/unreliable, but it
// matches the java version, see <http://speleotrove.com/decimal/dax3274.html>.
// Pass a MathContext object to an arithmetic operation to set a precision/rounding mode.
// Pass integers to set the scale (i.e. dp) and rounding mode for divide only.
// (Passing one integer to divide sets the rounding mode.)
// Default scale (i.e. dp) if no MathContext object or integers are passed:
// divide: lhs, add/subtract: max(lhs, rhs), multiply: lhs + rhs
new BigDecimal('100').divide( new BigDecimal('3') ).toString() // 33
new BigDecimal('100').divide( new BigDecimal('3'), new MathContext(5, MathContext.PLAIN, false, MathContext.ROUND_HALF_UP) ).toString() // 33.333
new BigDecimal('100').divide( new BigDecimal('3'), 4, BigDecimal.ROUND_HALF_UP) ).toString() // 33.3333
// BigDecimalGWT
// Rounding modes 0 UP, 1 DOWN, 2 CEILING, 3 FLOOR, 4 HALF_UP, 5 HALF_DOWN, 6 HALF_EVEN
new BigDecimal('100').divide( new BigDecimal('3') ); // Exception, needs a rounding mode.
new BigDecimal('100').divide( new BigDecimal('3'), 0 ).toString(); // 34
var x = new BigDecimal('5');
var y = new BigDecimal('3');
// MathContext objects need to be initialised with a string!?
var mc = new MathContext('precision=5 roundingMode=HALF_UP');
console.log( x.divide( y, mc ).toString() ); // '1.6667'
// UNLIMITED precision=0 roundingMode=HALF_UP
// DECIMAL32 precision=7 roundingMode=HALF_EVEN
// DECIMAL64 precision=16 roundingMode=HALF_EVEN
// DECIMAL128 precision=34 roundingMode=HALF_EVEN
// Note that these are functions!
console.log( x.divide( y, MathContext.DECIMAL64() ).toString() ); // '1.666666666666667'
// Set scale (i.e. decimal places) and rounding mode.
console.log( x.divide( y, 2, 4 ).toString() ); // '1.67'
// DOWN is a function, ROUND_DOWN is not!
console.log( x.divide( y, 6, RoundingMode.DOWN() ).toString() ); // '1.666666'
console.log( x.divide( y, 6, BigDecimal.ROUND_DOWN ).toString() ); // '1.666666' ).toString()
*/
// GWT pow argument must be Number type and integer
if (bdM == 'pow' && isGWT) {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
bdRs[i] = new BigDecimal(xs[i])[bdM](ys[i], mc);
}
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]), mc);
}
bdT = +new Date() - start;
}
// DECIMAL
if (bdM == 'abs' || bdM == 'negate') {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
dRs[i] = new Decimal(xs[i])[dM]();
}
dT = +new Date() - start;
} else {
start = +new Date();
for (i = 0; i < cycleReps; i++) {
dRs[i] = new Decimal(xs[i])[dM](ys[i]);
}
dT = +new Date() - start;
}
//********************************************************************//
//**************************** END TIMING ****************************//
//********************************************************************//
// CHECK FOR MISMATCHES
for (i = 0; i < cycleReps; i++) {
dR = dRs[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 !== dR) {
$RESULTS.innerHTML =
'<span class="red">Breaking on first mismatch:</span>' +
'<br><br>' +xs[i] + '<br>' + dM + '<br>' + ys[i] +
'<br><br>BigDecimal<br>' + bdR + '<br>' + dR + '<br>Decimal';
if (bdM == 'divide') {
$RESULTS.innerHTML += '<br><br>Decimal places: ' +
precision + '<br>Rounding mode: ' + rounding;
}
return;
} else if (showAll) {
$RESULTS.innerHTML = xs[i] + '<br>' + dM + '<br>' + ys[i] +
'<br><br>BigDecimal<br>' + bdR + '<br>' + dR + '<br>Decimal';
}
}
bdTotal += bdT;
dTotal += dT;
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;
}
};
// Decimal 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;
dM = dMs[this.id];
$BD.innerHTML = bdM = bdMs[this.id];
};
}
$INPUTS[1].onclick = function () {
clear();
$R.options.selectedIndex = lastRounding;
dM = dMs[this.id];
$BD.innerHTML = bdM = bdMs[this.id];
};
// Show/hide BigInteger and disable/re-enable 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];
}
$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];
}
$INPUTS[1].disabled = true;
$BIGINT.style.display = 'inline';
}
};
Decimal.config({
precision: 20,
rounding: 4,
errors: false,
minE: -9e15,
maxE: 9e15,
toExpNeg: -9e15,
toExpPos: 9e15
});
// Set defaults
$MAX.checked = $INPUTS[0].checked = $GWT.checked = true;
$SHOW.checked = $INT.checked = false;
$REPS.value = DEFAULT_REPS;
$DIGITS.value = DEFAULT_DIGITS;
$SD.value = DEFAULT_PRECISION;
$R.option = DEFAULT_rounding;
BigDecimal_GWT = BigDecimal;
MathContext_GWT = MathContext;
//if ( !MathContext ) throw 'No MathContext!';
BigDecimal = MathContext = null;
// 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;
MathContext_ICU4J = MathContext;
BigDecimal = MathContext = null;
$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.
This javascript version is used by the gwt_math project.
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>

@ -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

File diff suppressed because it is too large Load Diff

@ -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);

@ -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.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,615 @@
var count = (function pow(Decimal) {
var start = +new Date(),
sum,
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
function T(base, exp, expected, pr, rm) {
total++;
//if ( total % 100 == 0 ) log( total);
Decimal.precision = pr;
Decimal.rounding = rm;
var actual = new Decimal(base).pow(exp).toString();
if (expected !== actual) {
error('\n Test number: ' + total + ' failed');
error(' ' + base + '^' + exp );
error(' Expected: ' + expected);
error(' Actual: ' + actual);
error(' pr: ' + pr);
error(' rm: ' + ['UP', 'DOWN', 'CEIL', 'FLOOR', 'HALF_UP', 'HALF_DOWN', 'HALF_EVEN'][rm]);
log('');
//process.exit();
} else {
passed++;
//log('\n Expected and actual: ' + actual);
}
}
log('\n Testing pow...');
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
/*
Fails due to the result having zeros or nines as the first 15 rounding digits:
Exact: 839756321.6408851099999999999999999999999999998969466049426031167...
// Wrongly returns 839756321.64088511 for both
T('28', '6.166675020000903537297764507632802193308677149', '839756321.6408851', 8, 1);
T('28', '6.166675020000903537297764507632802193308677149', '839756321.640885109', 9, 1);
*/
T('9', '0.5', '3', 7, 4);
T('9', '0.5', '3', 26, 4);
T('0.9999999999', '6', '0.999999999400000000149999999980000000001', 39, 4);
T('2.56', '6.5', '450.3599627370496', 16, 1);
T('1.96', '1.5', '2.744', 15, 1);
T('2.25', '9.5', '2216.8378200531005859375', 23, 1);
T('11.05', '2.00000000000000007', '122.103', 6, 4);
T('10.5', '3.000000000000000002', '1157.63', 6, 4);
T('1.00000000000000000003', '4.00000005', '1.000000000000000000120000002', 28, 4);
T('6.0000005', '1.00000000000000006', '6.000001', 7, 4);
T('1.0000000000000000000005', '49.0000000000000000000002', '1.000000000000000000025', 22, 4);
T('15.333333333333333333', '28.33333333333333', '3917746643938779840069598486694964.98308568625045', 49, 4);
T('7.537714', '7.9', '8515169.08260507715975', 21, 4);
T('6.951', '9.225', '58598464.57', 10, 4);
T('6.01093', '9.8911', '50651225.3819968681522216250662534915', 36, 4);
T('8.7587', '4.23', '9694.37298592397372', 18, 4);
T('5.1749', '7.7267995', '328229.2815443039852', 19, 4);
T('0.16', '-0.9999999999999', '6.2', 2, 4);
T('0.4', '-20', '90949470.1772928237915039063', 27, 4);
T('0.5', '22', '0.000000238418579101563', 15, 4);
T('32', '0.4', '4', 1, 4);
T('4', '2.5', '32', 11, 4);
T('4', '5.5', '2048', 27, 4);
T('16', '23.5', '19807040628566084398385987584', 29, 4);
T('16', '26.5', '81129638414606681695789005144064', 35, 4);
T('25', '13.5', '7450580596923828125', 39, 4);
T('32', '28.2', '2787593149816327892691964784081045188247552', 43, 4);
T('32', '3.6', '262144', 35, 4);
T('25', '21.5', '1136868377216160297393798828125', 31, 4);
T('9', '8.5', '129140163', 19, 4);
T('4', '7.5', '32768', 13, 4);
T('9', '5.5', '177147', 13, 4);
T('4', '6.5', '8192', 10, 4);
T('6.034', '0.25964', '2', 1, 4);
T('9', '4.5', '19683', 16, 4);
T('9', '2.5', '243', 28, 4);
T('9', '1.5', '27', 12, 4);
T('9', '1.5', '27', 5, 4);
T('9.61', '3.5', '2751.2614111', 12, 4);
T('9', '8.5', '129140163', 30, 4);
T('9', '2.5', '243', 22, 4);
T('4', '6.5', '8192', 8, 4);
T('4', '7.5', '32768', 11, 4);
T('9', '4.5', '19683', 5, 4);
T('48.9262695992662373981', '1.0', '48.926269599266237', 17, 1);
T('1.21', '0.5', '1.1', 2, 1);
T('12.96', '0.5', '3.6', 2, 3);
T('3.24', '0.5', '1.8', 2, 1);
T('70.56', '0.5', '8.4', 2, 3);
T('90.25', '0.5', '9.5', 2, 3);
T('2.56', '6.5', '450.3599627370496', 16, 1);
T('1.96', '1.5', '2.744', 4, 1);
T('999000.25', '0.5', '999.5', 5, 4);
T('4.41', '6.5', '15447.2377739119461', 32, 3);
T('11.05', '2.00000000000000007', '122.103', 6, 4);
T('10.5', '3.000000000000000002', '1157.63', 6, 4);
T('1.00000000000000000003', '4.00000005', '1.000000000000000000120000002', 28, 4);
T('6.0000005', '1.00000000000000006', '6.000001', 7, 4);
T('1.0000000000000000000005', '49.0000000000000000000002', '1.000000000000000000025', 22, 4);
T('5344.87762641765349023882127126550721', '1.0625', '9139.7407411741874683083843738640173291', 38, 1);
T('390625', '2.5', '95367431640625', 14, 3);
T('4294967296', '1.4375', '70368744177664', 14, 3);
T('0.999999999999999999', '2.29', '0.999999999999999997710000000000000001477', 40, 4);
T('28', '6.166675020000903537297764507632802193308677149', '839756321.64088511', 17, 0);
T('91.180153837', '0.5', '9.54882997214842023704943457512609', 33, 1);
T('16', '26.5', '81129638414606681695789005144064', 35, 4);
T('25', '13.5', '7450580596923828125', 39, 4);
T('4.3985903', '20.9956530307', '32120869378609.033520730996715368034448124619', 44, 2);
T('2.858368', '48.97', '21682301291468972839895.193017121528607658932', 44, 5);
T('91.145', '23.8479557348417627', '54402923894673605836306983589686900000000000000', 33, 1);
/*
T('19.573692', '39.26449896890', '521054762573404555504167445689791315945776225706079.2116169842543900194096', 73, 3);
T('39.930616507', '42.75527260683915249287', '291256227754122949217889951695109090756624015235199291012218659859430.1483885', 76, 3);
T('26.83062706567369901840006672503178674304033559618349', '33.97599448561040496576773597688798140377713162', '3460612383084345697566784116666546471243869942274.645400309266443336139010350455115437597342796396780325323658', 109, 4);
T('47.135718860729672020084081', '3.05', '126974.90929240431902383117376127315256838006780434227504056037805', 65, 4);
T('18.67753133', '20.9', '372029173771636488825923373.24368101909925322135384712128889742', 62, 4);
T('0.489692498552144752316290764961721145017762201246086586011796456968995995969396377681', '73.369662', '0.00000000000000000000001777413292817808875302333322248871556548370900264362859174427090747064763', 73, 4);
T('0.2099424284425661993789657104284654051840652083412425216783104125771311', '1.8542', '0.0553398810557535646400543292708622414221770030552096817266128959560806156909100492590093948271', 93, 4);
T('48', '47.00000000006', '10431293299578300472505722493977127156669827052412267550640375015611511073910913.00531047503932427870602874919343580355903603249536669162057', 139, 4);
T('0.838625145339541271701779', '94.77593582', '0.000000057026184458450818565687361276199680034303594036642041738789609293', 65, 4);
T('40.098683536988660067035248', '40.00000000000000000000000000004', '13341497789508672160655257782814705308380068881069319519274710828.0510014812189671113037267510437119', 99, 4);
T('6.7230783647381181879144192', '36.99999999999999999999999999', '4168909024084299883499172453439.92952620058282432135208362904491979626334626', 75, 4);
T('39.827734210552778790888', '40.99999999999999999999999', '405144183872563552639525122722590290945106980493132837196819477406.2493257487373426610525895206833', 97, 4);
T('44.06836778444502', '16.99999999', '8915760497864097881057047385.1589321368280183450665841730522629478192616', 71, 4);
T('20.48125478194761957371727', '44.999999999999999999999999999999', '102575869173172687693623536696277218136268269250881789151455.5599587539313661506308343751829071', 94, 4);
T('25.7', '34.9', '16094074385237190707184756692452184305918209248603.03437636908', 61, 4);
T('25.648733787941182939757019123', '42.0000000000000000000006', '151624387302245711852361685116892093436785716023010596705862.905859238770884707617030065289418650604180572596634880557', 117, 4);
T('29.815418285970618948', '49.00000000000000000001', '1768497375108123883211511704270568373888734104562897895967054691907030085.702823746498', 85, 4);
*/
T('5.379973182', '2.65', '86.4', 3, 6);
T('625', '4.5', '3814697265625', 13, 0);
T('65536', '1.25', '1048576', 7, 5);
T('9', '1.5', '27', 2, 8);
T('256', '1.625', '8192', 4, 8);
T('65536', '1.875', '1073741824', 10, 6);
T('65536', '2.5', '1099511627776', 13, 1);
T('4', '3.5', '128', 3, 3);
T('65536', '0.3125', '32', 4, 1);
T('65536', '0.75', '4096', 4, 5);
T('625', '5.25', '476837158203125', 15, 4);
T('0.16', '-0.9999999999999', '6.2', 2, 4);
T('3.6361', '-0.06', '0.92547', 5, 4);
T('8.7881541', '-0.00000006', '0.999999869595727123998', 22, 4);
T('5.812', '-0.99999', '0.17206083953928505581714758136682954', 35, 4);
T('1.00182', '-0.99', '0.99820145697169941929781173763757', 32, 4);
T('5.5444262906750381', '-0.000000000000000002', '0.99999999999999999657441', 23, 4);
T('6.06737421654397', '-0.000000000001', '0.99999999999819707407228698', 26, 4);
T('5.57197470953405387', '-0.9', '0.213', 3, 4);
T('8.4297580531324', '-0.000000000000002', '0.99999999999999573646385819', 26, 4);
T('1.746122696164', '-0.9', '0.605526', 6, 4);
T('5.74274073282643192871', '-0.000000000000004', '0.999999999999993008253696156596264156', 36, 4);
T('9.66306878602393217324', '-0.999', '0.1037217997755957147', 19, 4);
T('5', '-0.9999999', '0.200000032188760838972540436', 28, 4);
T('4.3824878980139638', '-0.9999999999999', '0.2281808925138899469268430741', 28, 4);
T('5', '-0.000003', '0.9999952', 7, 4);
T('9.334054292', '-0.004', '0.99110511776926013256649456014581966281', 38, 4);
T('2.857025525067229367', '-0.9999', '0.3500511195441991531149', 23, 4);
T('6.15', '-0.00000000009', '0.9999999998365193126497', 22, 4);
T('3.7546658482323', '-0.9999999999999', '0.266335285328', 12, 4);
T('5.224911080753249', '-0.0000000002', '0.999999999669312', 15, 4);
T('9.95213178392941249', '-0.000001', '0.9999977022158620465445576', 25, 4);
T('5.7886', '-0.000000000005', '0.999999999991220548', 18, 4);
T('8.0710798936715749', '-0.000006', '0.9999874703547618', 16, 4);
T('5.676593873395780714', '-0.0000003', '0.999999479094720867', 18, 4);
T('0.0157695061', '-0.999999999999', '63', 2, 4);
T('21.8005326254960840089', '14.99999999999999999999', '119400615273418803650.1362563340821916898208389', 46, 4);
T('46.80102307015', '4.000001', '4797589.19437982876031', 21, 4);
T('29.255206217375', '9.9999999999999999999999999', '459231465846284.22207', 20, 4);
T('0.72591761772', '6.999999999999999999999', '0.106221237503302998', 18, 4);
T('15.4118713082497485', '0.9999999999999999999999999999', '15.411871308249748499999999995784640395270841', 44, 4);
T('28.4081968639389', '11.8', '141460533914213599.43787', 23, 4);
T('0.3928066161887', '32.0002', '0.00000000000010319062643292561810866879769121849802', 38, 4);
T('24.798046085018648753453', '5.9999999999999999', '232543806.207', 12, 4);
T('20.485568584242', '18.99999999999999999999999', '8270131718672851271097903.87621818958353436851582', 48, 4);
T('42.8370908953833379325104378096', '0.9999999999', '42.83709087928771082404132296717420023028537565', 46, 4);
T('27.0796495092501825688964546', '11.00000000005', '5742135400426759.88475582631790390070483164414', 45, 4);
T('14.1156212914776333444958455', '1.999999', '199.25023697213730437422455790987056', 35, 4);
T('0.1823257652020553', '42.2217', '0.0000000000000000000000000000000619081603070606529100642938807884', 33, 4);
T('0.85023814', '21.11452134', '0.032529930015511087700837705442326', 32, 4);
T('0.709391244588543909409761011308150363507899772705872604200789038324780375', '9.12701096', '0.04355', 4, 4);
T('0.8414635711869', '10.3112', '0.16866469404646128907003917377733', 32, 4);
T('3.60', '-1', '0.2777777777777777777777777777777777777777778', 43, 5);
T('4394.46', '-1', '0.0002275592450495', 13, 2);
T('969.0', '-1', '0.0010319917440660474716202', 23, 4);
T('8.97', '-1', '0.111482720178', 12, 3);
T('61766796871807246.3278075', '-1', '0.00000000000000001618993', 7, 0);
Decimal.toExpNeg = Decimal.toExpPos = 0;
/*
Fails due to the result having zeros or nines as the first 15 rounding digits:
T('5.631494596755272325099275679497505022190851E-85579855160', '-4.380603843574597881680471605766E-351772', '1.00001', 6, 2);
T('1.54725732121174158E+13424', '7.681985316868594141252366283E-70646641813731', '2', 1, 2);
T('3.1798831663344988E-78494755872861', '8.66070402471402816755433578062455886E-5900', '0.9', 1, 3);
(Make sure toExpNeg is set so toString uses exponential notation or this application will fail
when trying to log e.g. new Decimal('3.1798831663344988E-78494755872861') as it will run out
of memory trying to use normal 'fixed-point' notation!)
*/
T('9.9999999999999', '2220.75', '5.623413251778e+2220', 13, 1);
T('0.9999999999999999991999999999019999949909999999', '2220.75', '9.999999999999982233999997e-1', 25, 1);
T('987504387560932846509387650789.49807365', '981459.4903857', '9.876e+29438424', 4, 4);
T('-2', '1001', '-2.1430172143725346418e+301', 20, 1);
T('-2', 1e6, '9.9006562292958982506979236164e+301029', 29, 0);
T('5.0771598579583468811E-101844', '7064449.87442997380369702938801116641723585825702571602', '3.907934864857193219594361275098983e-719466848189', 34, 1);
T('5.80246472674775E+21125581', '0.00077726506294426495082193497633668602085', '1.5018938138904125617523547e+16420', 26, 3);
T('6.79814531138172811146427639311641731E+3002', '921333.540141164765345827196802875063582247147527560444072816', '5.46796747665387723536e+2766610196', 21, 4);
T('6.5682926973887749938950364924863319424161626660461642009258E+4917387197097215', '-7.473344492898604115409998651708493960E-8', '5.1432092531946772355e-367493286', 20, 5);
T('8.5584843207389113768089262878530505250100133967822E+319264126', '4.4104952652598E-7', '6.475779017455885133163196967776853546e+140', 38, 1);
T('2.2E-85790816', '8.460028062421713597703181700157526623479295', '1.0935729098864136591458e-725792708', 23, 6);
T('6.95700356503674177773968765540131122E+101', '0.000211632455594172697231298140755613', '1.05088008501037478144463478588688e+0', 34, 0);
T('3.3316637995391385961633264550E-3772960791958671', '0.000784672027200673851569', '1.349e-2960536793175', 4, 5);
T('3.0332704812020656734919659194988434164516141443309417146E+2375752', '84923.18', '6.11472957964e+201756455656', 13, 6);
T('3.331031860068154E+31107', '548.388652532680608435775902486969187', '2.458163170095818634716945e+17059012', 25, 5);
T('6.158616065490231075328019700927848134714359968E+6586', '396825439.1781141105070705573415309972949738857215903', '1.1750895091378313509383824e+2613805629417', 26, 4);
T('4.859961965493268964638E-7819', '5696158198.72674162171585785793670944491', '1.321e-44534349786390', 4, 2);
T('3.308275915E+77212864266', '8.371E+8', 'Infinity', 15, 2);
T('9.43310662617420078049146370844152509E+64581877644', '5.9E+3', '2.903932226338996143527e+381033078105350', 22, 5);
T('1.81266947641829295657247077144694660E+832281', '68616995635.8663593755366737573587973504301621883', 'Infinity', 32, 4);
T('2.4E+1232', '0.748899744138', '8.49620298398677665e+922', 19, 3);
T('7.25882410E+71552582111235', '0.000001959406007575585330174050', '1.7631972693126152338714709966936e+140200559', 32, 6);
T('2.62087885971273E-91339358825', '-1.79', '1.00225899699109514583960077804e+163497452296', 30, 1);
T('1.04229845E+4612', '2816.085044372115823938', '7.8e+12987834', 2, 5);
T('4.49936598066551281014136706696408646312061894590668335E-514963', '5.229545897987', '5.907717620117625e-2693020', 16, 5);
T('5.4312672321860831634015624847358227E-96', '3.869388648063353450784031014746833623069E-7', '9.9991512624172e-1', 14, 1);
T('8.1874305132863843004288479583988609288226775782721E-796', '86287636.018906365566916459137593560', '1.08225784e-68606164921', 9, 5);
T('6.97697061126899654376939048E+454', '32983.32837', '1.0523674190109e+15002258', 14, 2);
T('6.98646150526695482213630E+10094615260375', '-2.313568527197886888053736918475172855084', '8.80106745866762752508733009161638022e-23354584160578', 36, 5);
T('2.46E+6807810868902', '165504.792024627015721419216934101289417655264710125320', 'Infinity', 39, 2);
T('4.6611695937763727901764245452E+39357615164', '5523.187068356708641689', '8.375494973574516e+217379471118856', 16, 5);
T('5240.55860832754015401851361991154096', '81.967282733336603047726073', '7.36671523747e+304', 12, 4);
T('3.83293431846360497085E+22460014654', '87422.7917773', '4.43240217e+1963517184462762', 9, 0);
T('6.07976449380202695570672783218419418012688288182650E-8748574', '-80506.513335286282873749037045580619', '6e+704317126287', 1, 0);
T('2.70311705336978938471313110157167442061062340617691623846E+598', '0.70202658549705138907022833483536035235676707256314158432', '1.30340305614020216816816379e+420', 27, 3);
T('8.19226205828103067815656903723E+843283962', '4186782365.1454021709877368898656337749625995193632801484', 'Infinity', 15, 3);
T('9.048018220179838690160476412892178992790E-74561', '-544.861085646252181', '1.65238024e+40624866', 9, 5);
T('8.94153193419185952648109226E+37694850845765', '10.8990689418747722178108109013966', '4.684502779625540746956345543e+410838778121689', 28, 1);
T('8.355858242210290921583866619038461E+1533967231604', '22040.8342164255071260853405101881310229095792451834063628', 'Infinity', 34, 4);
T('7.980784424596730E+62', '4549.220335716', '1.840391265091332722600312840171e+286155', 31, 1);
T('7.353793980179257379112856201773846699826E+63830864934175', '6.816271825625622855541621907720102171265393461137E-7', '4.222928698030893636e+43508852', 19, 2);
T('3.5799714878406968191E+65297038918762', '50278.1386257334759042626769371626290015637481449605692480', 'Infinity', 2, 2);
T('9.6243636096055922536521273111E-396', '5920618332.4326756700062568987705', '5.27990794084958590687701576193e-2338742689221', 30, 1);
T('5.351524841596585527066548007832595450540E-6900660083423', '0.3513412144597333826620514746180947', '4.11193187e-2424486294284', 9, 4);
T('1.853556718499932114426541936E+87654', '4772290.7596925542935273123122793454667963', '1.18946271575922949592807590800617143e+418311653252', 36, 4);
T('2.9932243988603051613029655E+27095', '-49137.21272', '1.565591758733e-1331396175', 13, 2);
T('4.90835642540615754207791719888139323287038500600086187406E+323995843', '-3.1175E+6', '5.41202651005644161199476215577532225692e-1010057042706494', 39, 6);
T('5.53917753642534662031903215871385102E+719028', '8.1E+9', '1.5420589888668e+5824132821906808', 14, 5);
T('3.2463970188013098129842820589447516E+7509397560', '19896572.09822722893235765', 'Infinity', 11, 0);
T('7.86510933113092958285533647370800403533108E-19310', '5.8863560225170047649418509E-8', '9.9738629742634280669669172195959185e-1', 35, 5);
T('3.5594168562027049179E+7780564249923203', '3E-18', '1.0552167897899870873293090075940144622e+0', 38, 4);
T('69262535.5060474103', '-13701.9178481573095', '1.365303342599745517073745221651537e-107430', 34, 0);
T('1.431397648211E+7603955804', '6.2765078776416', '1.05e+47726288506', 3, 4);
T('9.0968190675810127390972E+17349114939', '0.00000882667333358649266115914874355997', '9.336881826930216e+153134', 16, 2);
T('3.76588033E+822', '0.0001025529515887847663397222156277393409085154', '1.21438832417858515403929485e+0', 27, 3);
T('5.84501760745660235389485148944652846220E+9248288815', '0.00084325421', '3.014333197311981074259e+7798658', 22, 4);
T('0.00006614', '0.000022049910', '9.99787819981949439235657385e-1', 27, 0);
T('6.0003208406152355926310469716974209910327314295650E+64687794611878', '26.033510753168627099254060752011047584021484263', '5.601446439e+1684050396627109', 10, 6);
T('8.117008383E+7158', '7.2706271498941212636904030030133919192533E-8', '1.0011992085e+0', 11, 5);
T('1.72811288429651131465175588156671220359452E-5707034846881', '-4.0575454834840E-7', '2.2217985751061080605642e+2315655', 23, 3);
T('97637051849.909438339567842', '371555035308793.9080622141370606183291955840592937678786', '1.06144413718216162422462354574978e+4083246662069331', 33, 0);
T('5.985096633413813E+561', '65806633.2539333000586861147953697705287386278592235253549', '5.5055533269431429514779e+36968657692', 23, 6);
T('53267011.744272861578238255240403493261783374', '-493.941494308794718', '3.8161454359118554948e-3817', 20, 6);
T('2.746E+6364504', '39.9168044722206079756625576923335472842051765968348001100', '1.746583455543525803633334398e+254050679', 28, 2);
T('9.9387668014142760681370651297E+7614474059', '1712188781.21879322628323956883', 'Infinity', 2, 2);
T('3.53014084524946', '4.871197491025608341402076679526556E-7', '1.0000006144227266e+0', 17, 3);
T('2.9014E+690', '-0.048', '7.20766901141632909675632494993e-34', 30, 5);
T('6.7737932249914149192741904436033502881E+69749', '-0.053022712987606', '5e-3699', 1, 6);
T('3.6882175649704684277757828E+2037964874', '-642635.8362223765343131663196387750446', '1.4267857980606754101453788797453e-1309669261359077', 32, 4);
T('5.11991785183E-3964466', '50.479', '3.88049042607e-200122244', 12, 2);
T('4.0005860432176758E+78488494356638', '57557.576405933488417239933136101256516304401', 'Infinity', 21, 1);
T('9.5028642420663381800682029705240338162178980457016913E-8546023572', '-0.00003840168085460067309845988710067', '4.6746627792e+328181', 11, 0);
T('7.2465E-6395778', '213.7585955518485060854', '1.3134275713320485356634e-1367152339', 23, 4);
T('4.33901448445764731784110608985303169833582431444289375174E+60516785149', '9902352.6183715624163', 'Infinity', 30, 6);
T('4.76328474150765985910452135589930147653518708469312875497E+583612573', '7629595.9208504002813101957894', '2.86346770725041477546361444032302e+4452728111489959', 33, 4);
T('7.9554083492767223354864588228489828334013896455028E+13167', '2015.66', '4.46e+26542010', 5, 2);
T('5.04931440384197989038621792283832975822144434473E+63', '-17.149639619768469086', '3.25477890437150725e-1093', 18, 3);
T('8.214177E+75966888071', '30364.45069179876052659964380366664253430364446270', '1.562389342311588854940141e+2306692827069045', 25, 3);
T('1.4075196025653192682742670275E-39122', '940954025.6674305831', '1.036554486499e-36811863703347', 14, 6);
T('2.2986590678229284E+370392870', '97345814.5277182390478328722819235', 'Infinity', 13, 1);
T('5.57683020911537577257633E+934917303658982', '-4.25311611870491E-29', '9.999999999999084420360023414484177e-1', 34, 0);
T('1.0710075288038136528515644237139732E+65', '0.047725273191322320664747', '1.2693009753583437170918352992764072e+3', 35, 1);
T('8.1497979533468E+597', '556752.315192836410882451812697427370835264116', '1e+332888415', 1, 1);
T('2.930060170451323886761623608554032477037784145174641645E+73', '-3E+8', '2.094454199984211528355892628727511e-22040062962', 34, 0);
T('9.8577E+825206092718303', '0.0022110', '1.47955202e+1824530671000', 9, 5);
T('7.9742E+95828', '206800229930477.1323', 'Infinity', 37, 3);
T('5.753890382013E+6807473988', '0.0754264073573', '1.4139e+513463306', 5, 5);
T('1834764.958079827578616321', '-97006188.4597939293840381191', '4.947542073173793689074414906442045865e-607606065', 37, 5);
T('7.440727008114541286497954414408496303E+98487561', '-7980827.272482942', '8.0146608376457224435682604305e-786012219785340', 29, 2);
T('9.55999593025822561160479338E+95', '-666.3', '1.66352588e-63952', 9, 3);
T('2.620771502858155704600372178644271310074352903507500091933E+66', '2.44590333E-9', '1.00000037406205743668737376e+0', 27, 5);
T('6.709010827115311E+914391225959413', '-8.864064', '2.7416639030849663228e-8105222347942706', 20, 3);
T('3.71568864935547034975803653196471500933089027829633338E+985253596', '6.26509982590332709822605393', '2.195736341659688677851565131e+6172712136', 28, 6);
T('6.745917715273634386E+54700229624', '-48.1307174544', '3.571994854951e-2632761296764', 13, 0);
T('5.1915559970290E+991046', '8.54419746433086962914319198382480626592031790149020', '6.79013958295e+8467698', 12, 4);
T('5.2380448393914E+72874805286712', '14437.1570049050862864865489174497106479405265821687619154', 'Infinity', 32, 2);
T('5.16012974239479948692516586442121244564792300566067E+617', '1630375.763313280575759560950309321947537389455290', '3.705000256448983280647292442122119e+1007103750', 34, 6);
T('4.550743857579917E+89364924883381', '0.071624936256657', '1.4198730603177818398948e+6400757048353', 23, 1);
T('5.4784315202534954933752E+33', '50.89978170673732', '2e+1717', 1, 4);
T('4.4E+907314110', '0.01226922166800446010823682923592832', '8.83e+11132037', 3, 6);
T('5.63687872577834530360787E-951', '48675873.191927476517892157', '3.78490584626639e-46254197942', 15, 1);
T('2.57209445348531846179035553715262227407164720E+4946720729061', '-3.7', '6.0525505088486191940357e-18302866697528', 23, 2);
T('0.80783305227594822490', '557297197.1243805703436076820342175284400830676387253', '4.09225902098130174e-51649403', 18, 3);
T('4.584765738210609298576356293036301454E+8474495611292', '6065067.0540885155406011346202658116313', 'Infinity', 9, 6);
T('5.00462269496018478010950760E+86', '9.65131599505646981649097854341675891698966650224326820E-9', '1.000001926719933e+0', 16, 3);
T('7.563438E+67811136', '-7.17484326831E-23', '9.999999999999887971342205745603291224e-1', 37, 3);
T('5.9763980481068E+1113186691516091', '-1.3360029E-14', '1.3421267083913530666271523e-15', 26, 2);
T('8.713242E+5235499', '-1.98292870076E-8', '7.87378893e-1', 9, 3);
T('8.8125725501017303078E+8159173492169', '6029591.745', 'Infinity', 24, 1);
T('3.369944959336926265579433954594E+97550306', '54706.112261688363166941820', '1.755708444492156e+5336598020062', 16, 2);
T('3.7542579994511004229761890E+1462024', '2.810223427334048', '5.1364818899e+4108615', 12, 4);
T('4.507548245236103246777419861328222395814830663351978233E+9215058605908', '-0.6226090733453', '3.809876e-5737379099448', 7, 1);
T('2.51462213040697818603313246450951120892996E+9291832004', '504766.1995653938766024498921253', '6.5029475983490433746195009480676346e+4690202727861322', 35, 5);
T('7.3371675684192595774004205491887147259123372644191', '2902867.20003859346149086963501957958204041508964563', '1.29598827535234984271e+2512514', 21, 5);
T('1.25251232761437105495117783119126533219961471789108E-5601273319', '-73.6512577287927218140', '7.55e+412540824819', 3, 2);
T('8.1374782496336891E+87410194', '-0.0300', '1.4213e-2622306', 6, 4);
T('8.62212E+367', '-0.002', '1.8370829727622e-1', 14, 5);
T('5.92239414115944307485175893092142735501E-154', '-76.672520121779641068399680167', '2.181641865067e+11748', 14, 2);
T('6.125403043035592435596824426852943151660022E+5926', '65982.22675024794740311740587742', '4.17e+391062612', 3, 4);
T('7.284395660349E-82911613', '-9609.96811006787033383524', '5.18055574826116314136620021678343156834e+796777948596', 39, 3);
T('4577422398925031174823401.4196752295172101319597154983601', '7578796.626513284235095426704781855453556696783', '1.47931e+186897831', 7, 5);
T('5.3915388253441339540763890176079700908597035262E-493205', '18684.486685', '1.59026e-9215268584', 6, 0);
T('6.5460E-11832', '26943775.67722264403338049703137405470', '2.69068080646213385260257e-318776768339', 24, 4);
T('9.552099614070226859748E+522250995', '-0.7134529193085892', '2.02385874463953e-372601498', 15, 6);
T('5.33014285366E+6640', '2432.874973546845', '7.7465526772753511221079778688948468e+16156057', 35, 4);
T('4.37816973238061550439E+390301', '-707574.56662380566870098', '6.80107457312003e-276167514691', 16, 3);
T('8791873.2220876986561305724198951917', '-7.353683E+7', '2.15519273455868576810119774e-510645735', 27, 1);
T('6.928788232907308442704857627923073270253E+7512187664588', '637.719', '7.501101953378144222062958121991e+4790664805273930', 31, 5);
T('8.557874958124599204654E-9845', '-0.532896', '7.31587e+5245', 6, 4);
T('7.909064231902852763550504721E+7729325055', '10782.8', '2.010741456085473198e+83343766212738', 19, 0);
T('9.70061858912969405080616286638669487950784703798672793112E+620158674087206', '0.0008073727586653391770700589465604878355224551', '1e+500699219508', 2, 1);
T('8.69544672318768645069891055702492801030E+836172024743991', '-0.9189385406', '9.0926178561400237931548536357520847e-768390700108792', 35, 4);
T('6.821907772029241562888E-641988722030697', '-8.80448692', '1.70950409898587409319546e+5652381305906780', 24, 0);
T('2.0394585080136797274515127800480935450E+55742195', '-4.5386E+7', '8.316594560489691e-2529915276317643', 16, 5);
T('1.19358632791080098547717793552706755853555741576544121E+39141', '-52659468.256521365038538341', '2.44162971679093437367642016e-2061148294111', 27, 6);
T('9.161790991723791509327994187198136437E+27457608255728', '0.56608958614148538780', '4.3708691505454533490744153012026e+15543466093920', 32, 4);
T('3.7662134744708956765426105833763348E-71455', '0.000023849088573800620787264793114229120799092187309', '1.97641031015543e-2', 15, 3);
T('8.55227544534E+8270770351116', '50.9072', '7.67129163e+421041760418379', 9, 2);
T('4.1938542493600279390170E+17936185', '-64.54972137057845250657581129217599661506', '4.067561611914045705223241906316e-1157775785', 31, 4);
T('2.3131763547205E+55482', '-13.425', '1.8217870382263049170752492e-744851', 26, 5);
T('1.3E-342294', '0.002878457310386054168779994', '5.268189395464716053289828931549040674e-986', 37, 0);
T('7.50841253834314739444848074171321830077188975E-74633850', '356.83537735328009715320188771188828', '2.2307055348406240138303734200465e-26631997716', 32, 4);
T('2.245089E-50412198', '93814710.170868752', '3e-4729405711495575', 1, 0);
T('2.5E-347447417283', '0.000783016200', '4.16449753034885026620617386759699448888e-272056957', 39, 4);
T('7.823397170086362080613754691658200994307742E+1857542338153', '3.3820520498585415084271809358129658449416774684393466233244E-27', '1.00000000000001446554154895286784118693e+0', 39, 4);
T('9.81177E+403007713345', '-5.47717188142508023546353347241702598446', '8.2217378103780488829365161998610916336e-2207342515537', 38, 5);
T('2.4507353066731837649751451E-75', '-0.000006571206', '1.00112955418884528082016536140424e+0', 33, 6);
T('7.443641736509587181356E+3324827', '-5.3612350707639818490727538', '1.6200566747196711e-17825184', 17, 4);
T('9.7407E+746579', '3260.04', '1.008070522815792e+2433880626', 16, 3);
T('3.2777121934336912810168007444541E+4019', '5491.1165071333267136192272001652269029669351', '2.002586e+22071628', 7, 6);
T('2.75365674196783038E+65159448733345', '-2.433365097487755443408', '2.9557671819634e-158556728319266', 14, 4);
T('1.3719782532970653E+32', '-0.00008148246902734791777306700205', '9.93988522350500261151816388124855984e-1', 36, 4);
T('6.961684485831144504394149421043093841228143127163E-8025', '5.66143E-8', '9.9895452382e-1', 11, 1);
T('3.203870427796078788719169671144343627555783E+89712', '7.33187668691940303464671E-9', '1.0015156982510789881385334461275046784e+0', 38, 6);
T('7.9618158439774247953E+6050954789', '-2.347E+5', '2.841e-1420159089189768', 4, 1);
T('7.9E+782077019', '976562.32673916207', '4.603394230286315501e+763746954240456', 21, 5);
T('1.338774629507178454137999605147970822412281015E+9195075956131', '0.94557490379385372576241180588124664720593602777', '7.3739152723297e+8694633062595', 14, 1);
T('3.3871725596953124824987766938901600E+57339095732', '-0.000059214631484', '3.772006640709082760894149085217641432e-3395314', 37, 4);
T('6.5481E-95', '6.95724E+9', '6.14497093699163269210190386385737396e-655259889969', 36, 4);
T('3.92454353231273611169248335873251152E+776667749226', '364.62853054352776095853', '1.030364793896893243802149386975e+283195220121042', 31, 4);
T('1.09223483289341702621056648392354614E-2657', '-808657.510406641', '4.0826106964027262677172e+2148572020', 23, 4);
T('7.3192028959103777360131963180583077042853268703093277E+909404806829', '3.21374964647566381609483296249831645116503E-8', '9.857e+29225', 4, 6);
T('1.43936221446087376875177418385562336116306398607E-77138514', '2.2316071645634117628750263513039949045353476', '7.0274615942815e-172142861', 14, 2);
T('9.3681362983674339253637847554582064868169E-6771', '-185.856', '2.44581005644e+1258250', 12, 5);
T('0.0660729161751769793425262396174', '5.76079E+9', '1.9006934476039675787e-6797596965', 20, 1);
T('2.59169206971662705870749634961542664603329199E+66', '5.5439431053650', '1.5600115e+368', 8, 6);
T('9.532244485927074147056042839343098352851133654E-797', '6545795.735902209014765212577590', '1.1809880732e-5210589590', 11, 5);
T('27613038502066878502411859587573099052445296.2', '-1.68652421', '5.4388764684482822763706e-74', 23, 4);
T('3.2314084085186696773729515133529862999E+474903', '3.186E+8', '4.394e+151304258092243', 4, 4);
T('71687543.393833653743705678', '8.629920110176544750723537346352', '6.192293673677253e+67', 17, 4);
T('8.222747797878525869993E+91317', '-9.99160E-22', '9.99999999999999789909354665e-1', 27, 6);
T('8.782032315973218726E+5627', '0.0000802993830038751440486128543961702078086106587303', '2.830874e+0', 7, 0);
T('9E+36232707249683', '-42', '8.35246382862392181051107318287717484627e-1521773704486727', 39, 2);
T('1.188166725593E+544', '-0.45', '1.46657e-245', 6, 3);
T('9.17503208816241082159387326100949902389404587588091329E+668275179212400', '-1.629712147', '1.8121907731671607349e-1089096177101052', 20, 0);
T('4.1E-57107000', '0.0111452652464478005919', '2.21004310379622800709e-636473', 21, 6);
T('7.2705827518572846348071070646891039E-50748', '3963.8', '4.876199857456245466466770191856068e-201151508', 34, 0);
T('5.437359658062633910229422238566735067843E-945660337', '9680.4664615019518853239085297269260152309085298054533', '5.836e-9154433169183', 4, 0);
T('8.3115757068779638683226331235801E+757329828', '-0.00007729603672856076270523536275296440351', '2.5452367749e-58539', 11, 6);
T('6.006057907936150', '808871713.08629583895755330087321', '8.470500147971835274466193e+629779034', 25, 2);
T('7.64349884280629088310958E-8068', '-212685269.518065674123255802779', '1.7712674661492160384e+1715756891231', 20, 1);
T('2.82714844763001396760502449440039972193408245645350E+907093', '-1E-7', '8.11e-1', 3, 1);
T('6.76201289187997006065251E-68269336', '70932.8324936694129190381703980', '4.0405983775906402328865028619829e-4842537316063', 32, 4);
T('3.734209818208857153109408459940415845307E+7912847300793', '0.000189698810366761117108375455804010337923', '3.752990087054993356848550108925415e+1501057719', 34, 5);
T('7.48828005901074874086686327832442100176173E+84279001853606', '8E-7', '3.04008341073872128340614882098e+67423201', 30, 4);
T('7.871247861390195043E+47907686170495', '0.0004', '1.578913788610903e+19163074468', 16, 5);
T('5.9404972154762900249357516837332077722792095626831563824246E-38084', '-0.004506774727812020522', '4.2906322125800659457479280870392367149e+171', 38, 1);
T('5.4654499973740226777117297791777381085967091477327606E+76224', '1.9689685189928950122574', '1.284558656827135142718745725659803195e+150084', 37, 1);
T('3.646056615243E+42468777867', '0.083720729320335555346388072514697970850325559', '2.6037594032522493e+3555517056', 17, 4);
T('2.6847256147074E+90437079560', '4.08690700011586767E-8', '1.2e+3696', 4, 1);
T('7.44178450056353769408836251138199842205277120238697285805E+88', '0.107157559025034920881311018720', '3.3363e+9', 5, 3);
T('8.7866521890629663317944589103030337127017860556769958567E+9937909361255', '0.178841708489075337687476966466087538620', '3.876102911e+1777312688976', 10, 2);
T('1.19473123E+1564', '3E+4', '1.277867958134239380301278326131e+46922318', 31, 0);
T('7.938764945781384076E+6080', '5591.22202955', '4.5513695029114625344462377786170376109e+33999660', 38, 5);
T('7.04689441463039523454393363762155749287E+76770', '0.000172727313450498151', '1.821471271885195637858e+13', 22, 3);
T('4E-2927999089326', '2027.17000226244973117045613', '2.0204170898633160900595232224153e-5935551920532218', 32, 0);
T('599.02258214977740443955617518', '2888642.310254317240', '8.453571458419e+8023039', 13, 5);
T('4.08310428041776621844744313774309309337632383674874676901E+20625', '59815799.1620608322988665735554073', '7.101689325884e+1233737404600', 14, 6);
T('4.1108488871286023623810551774186079378367088863035879E+2931831', '756062.041074229677230', '1.028903677564269398e+2216646594115', 19, 4);
T('6.67583226737E+40793488463128', '4.1085963276748772345489E-8', '5.873900500171689e+1676039', 16, 0);
T('9.10556062199787E+59059201', '-7.349326599391897790150853257569184', '1.3e-434045364', 2, 2);
T('7.129001E-125', '-0.0000054853309260643627770', '1.00156926e+0', 9, 4);
T('9.349147200463064402434848793172841115669923581245789792E+95', '40666.0291024681928686859730843883', '1.610814e+3902750', 7, 3);
T('7.32478339660827386511904398146593223690892363724638067928E+147441930', '300.262378199884726565526139448', '7.018901219e+44271264807', 10, 5);
T('2.44194666894526283911E+4759', '-34564905.626613407', '4.498037884464906858017550598e-164507787942', 28, 2);
T('8.5450213030663475403925390862757928243049864470438068821E-9450653', '6.35212633430652189178965844844482991E-7', '9.92719178275547649159520009606e-7', 30, 0);
T('7.0812203847203896891657449E-5581550115241', '8.1537646404038798861907616340200074822849116449224943966', '4.6225104704125618131676851077924e-45510645968288', 32, 0);
T('5.4365124537572282251220801129890472069264624E+70709860', '-0.00003302', '1.446766752e-2335', 11, 5);
T('7.2564079797525275842223957575199099725533628583581940840E+525563', '30.32848064460663', '2.3845288309557631899791305078047e+15939553', 32, 1);
T('3.761438485653425132373312148474923170770E+375447975335', '8E-8', '6.88694866883939275e+30035', 18, 5);
T('9.29633132E+5952905852880', '-0.0029', '4.417656017858392443e-17263426974', 19, 6);
T('5.69617994228945675175806014587356905822E+772166', '372305.495181063218348152640', '8.80069187860397927278408742239219255e+287481926299', 36, 6);
T('4.74E+756531', '7478.67938838032168930600074020614170549325489434482', '1.9966784918136155e+5657857850', 17, 0);
T('7.1498486769103546629735019198841931936605158871558742248E+442233623632', '-141.1530358', '1e-62422618508612', 1, 5);
T('6.3699159330279977330578689630950297498906351447828942E+88752', '-9877.93987', '2.974517e-876694863', 7, 0);
T('2.1328E-36076527', '6484.9682191578845045274', '4.3632949345006979377e-233955128920', 20, 0);
T('4.4317422553267864709042786956854797718571024E-867279', '-2967836.1', '5.94447835368052268717797409736e+2573940006044', 30, 2);
T('8.640940138781391559424163634E+47815331749824', '-0.030066097865616139762783845988967984', '7.25827e-1437620443868', 6, 3);
T('3.7356551798388343706037572965284E+9614946926', '-0.00049745287539654218001000857107912624723', '1.010628241547351094711841349951e-4782983', 31, 5);
T('5.2756050421400918548432951313606520208189098E+50035', '929797933.6436569701770123124', '7.6563147963021741756726619e+46523111177128', 26, 2);
T('7.1899254058519432659426926220919793616925857627438640857E+3659864937', '-598.6927600737586618427', '2.4124217456891662165454e-2191134641143', 23, 4);
T('1.147487567601177441990531729624174624975867317214307844E-82', '39635.490730239834520560731748493755621945510', '7.961230862860157814045291e-3247743', 25, 1);
T('4863.50689', '-352.801969', '1.7256164978338917113502131045e-1301', 29, 4);
T('5.983818609426797113889418679604882639700955568868282478E+4135', '-2939574.320160534790658783891589522220', '2.114e-12157423800', 4, 1);
T('2.906681938358842060030144181578E+887483702748', '52.87997314882238401309343494285815550926401256750805107', '1.62430550691028547902178319e+46930114371356', 27, 2);
T('7.9114076584066097737338768E+7810323948903', '-0.000008740', '4.85937e-68262232', 6, 4);
T('4.6013912808758606017110871E-245', '3.4724995945188572159462668862516186993570565854787773131', '3.463233e-849', 7, 6);
T('8.594601824852994632773253829009423761767E+557233', '3296746.0179167050381799091063361088630662641', '6.88021020915406500327644e+1837058753706', 24, 2);
T('7.5065769223E+80945520', '44311579.91450835622099079475373793', '7.81666320504675306640165696e+3586823916993649', 27, 1);
T('8.39140435622E+881', '-49355269.733295166', '4.7902426e-43527588744', 8, 0);
T('1.85959539599127806116798728957747440888E+64897189', '-2.6282E+7', '9.426151184050998099496125481209146601e-1705627928378857', 37, 5);
T('2.482E+9183945670', '20.3882516496848113757561147315860933', '1.102803875585527670088322714972305841e+187244595465', 37, 1);
T('4.82067355244004903214465213245729406158094749631E-4958', '-0.08613523', '9.99150014879904732387152377e+426', 27, 1);
T('5.45489356136239491363420910615E-38246937', '0.00000177960423531323264', '8.6216470171421929946987e-69', 23, 1);
T('2.36489347E+934055', '-28342.77814832234', '6.45e-26473724239', 3, 3);
T('4.59940067802489686883617006546003868327E+37431515', '64562.77354657730260142402011', '1.3864514223597113686522e+2416682469236', 24, 0);
T('8.25778322918239224333700772E+45482332', '773.883851735802787007611159390733795544441207116', '5e+35198042983', 1, 0);
T('74957.412246810792788884', '7743629200.8', '7.7e+37748756568', 2, 0);
T('5.5140024230792986213477732E+46', '798841.8366676098559674270965707126110', '2.0368858e+37339039', 8, 0);
T('5.263098291053805792559892617E+907', '2.65434903844893480535683930140208648600653442333201753208565E-9', '1.000005547884646151963e+0', 22, 4);
T('3.72311056860059868316321066085162037831468066579239E+9616846', '45907.2931958298442867129221121393217397371634022886148924', '7.75454454970947579884565287808e+441483395149', 30, 4);
T('1.8435082851888111442344443479166058249790453557211910602085E+66580', '-811597643.0841915477732597508620', '3.327849082473907e-54036386673478', 16, 0);
T('3.697260569406113319191698322074299748896E+7007', '0.767414997683490424098482169261805723369074', '5.160460313809209592313139909738897e+5377', 34, 3);
T('1.030879593520268877343557289105932959940209596180848E-6318', '397676.7782919784', '1.7514771349443e-2512516633', 14, 2);
T('9.625504980110E+7481970126', '535.53888926403366458', '2.42e+4006885971311', 3, 6);
T('7.330323521200187837671246094104583822799328503E+9334141699', '268352.91263137194944787357894327786548389', '1.10660785621471227475e+2504844112072751', 21, 3);
T('4.4336827185427321390667790041004325510717185845E+60', '89263.5031865831713880817361626598956239275275668', '4.635718673528298714e+5413542', 19, 1);
T('1.25079709471385644710449496404342118731991905342280292898E+21637783', '2350.47024817547008354378018207097274', '2.581068333e+50858965406', 10, 1);
T('5.53246829839995757504726968715310499258089509906E-597577456288275', '-0.2166244923760343050240812392', '1.7376819214293845e+129449913123809', 17, 0);
T('7.2064422728991150451081E+51267', '1.8279665442660962695940418850500503013832513571', '8.486136664229787335127e+93715', 22, 1);
T('3.77674514690011642776690392706007538429237402416E+931689', '-0.07855666803914414227248331478053500567756', '3.72541651802324623e-73191', 18, 2);
T('1.55384497102883E+428', '68.61099016450983730355401071824', '4.33e+29378', 3, 0);
T('7.993753886259415047243487E+731', '0.075115850878944976379581850524075527386454652911', '9.4950637501933162377318864e+54', 26, 4);
T('1.55694709677077667744695642517697895675851211378519128968755E-6557325', '960218.7732664123136446682525958357247355335474469', '6.2e-6296466382785', 2, 4);
T('8.4841229368160708749841885639520852819355304533488478002389E+20041893179', '-175.33037889904506935', '8.51306752324188e-3513952725092', 15, 6);
T('3.95380677969906649473169361350477736189E+860242', '0.0009875111291836559', '3.156009854463035385748448e+849', 25, 2);
T('5.17765862660410322326190753569171688302197869975119296980E+31887', '8108801.4715061805569486683272503', '9.7473710156e+258571143287', 11, 1);
T('9.8037E+8565372', '-6.9513E+8', '1.6e-5954047727504940', 2, 3);
T('8.5824463221851411255451390877390329597E-691135604', '-2.58300768613E-20', '1.000000000041105946524850370999e+0', 31, 5);
T('4.65E+8408', '1.100806336824531989527921406283235367', '2.06260687380855310918629224033799014391e+9256', 39, 5);
T('1.77286546860978039E+99', '-326.9', '4.1e-32445', 2, 0);
T('1.35185540277151981999259893988649E-284264787', '20399.63950252065589048180573834991617383354705545180510120', '1.28679038528348e-5798899175390', 15, 0);
T('6.849E-840', '51086.64930', '9.55e-42870097', 4, 0);
T('6.6602105401918870666433687832649710523844366792E+133312', '4490277329.9', '5.27489899143156401591721518e+598611549092938', 28, 2);
T('1.758457604865791424956759785062684508E+84592205607535', '0.000031320288832705093938858330649', '4.203193313877024449105363795905e+2649452312', 31, 3);
T('4.0033339069914007725', '7.60', '3.78796356e+4', 9, 3);
T('2.284388102641739158542E+5530551', '41.3185268990586415428666623018911748325062', '1.21327431814278462548162760804e+228514235', 30, 4);
T('3.57132804915297790220803545323363990096357450E+60206895652', '906.05507591133502027329713710032662543507720884', '3.8068514949e+54550763410859', 11, 0);
T('5.692772152E+94197814026', '-18339.58222956343515706', '5.92830168259179054432153606939e-1727548556188804', 30, 5);
T('7.25328470488639728818355758239482325579E-45889', '-2.5094E+8', '1.56181341790675344e+11515169717416', 18, 2);
T('8.240628335230944034E+59', '-0.0071582', '3.72485672782181269621869e-1', 24, 6);
T('9.6143417652E+11188471694', '-3664.729387511', '1.216755967826672619047537376934878e-41002721021939', 34, 4);
T('6.116288464121212556521322401415E+62640055', '6.048249564', '1.25765488188e+378862690', 12, 1);
/*
T('4.83628029309660850794678561230019450910E+87733370', '0.000096946874078351181196', '2.992541767394324327352611351e+8505', 28, 5);
T('9.278465437632054898250445034979667E-3411533', '-74948555.20599930965', '3.014021422725576e+255689396876648', 16, 1);
T('1.25889911E+91074388003765', '9.16132112850933597129872215799623', '2.60597498197169179853397492e+834361715084950', 27, 2);
T('6.596179572028988147714816320984358405248849185182E-50321157630', '-3.1377969545414611944110693090745829', '6.982962609147183908212783095228948119e+157897575157', 37, 0);
T('9.58392069153183684729238047926083631125244373E+42656096692584', '7.1717671015027382E-30', '1.00000000000000070440588975e+0', 28, 4);
T('7.661318880321572397749667E-1381360', '-9.499565E-9', '1.03067634978898338e+0', 18, 5);
T('2.77286593676762E+175763', '9067149562.4997587940364545', '2.93138387993618221847324872603067729e+1593673424655979', 36, 3);
T('568095.9372510733070324018457611381013912938299202025', '-0.0001252535917244547519557802378', '9.9834176e-1', 9, 1);
T('4.97659727820351798728808E-6377074587459', '-92.00335026219333632553', '2.1360328778365028938273987041939883e+586712226918058', 35, 3);
T('6.8196090591233160818359447259962978929E-94227678', '3.38607869E-13', '9.9992653588221917678836e-1', 24, 4);
T('20.8604803306814804527', '7064871160.020926910547997184555649910562127888', '3.562e+9320856227', 4, 3);
T('376.670709', '8792380.8982043452984', '5.75800883925415824e+22648837', 18, 6);
T('8.4893965818857E+35122969', '938781.8368690', '4.29877769563498730208541e+32972806226125', 24, 5);
T('9.419455861936004840298066576180551617206E+2934457554242', '380', '1.348372424976410799e+1115093870612330', 19, 0);
T('8.891024393928805446036075067072624175632488906876020657759E+19957856959173', '1.86579716295693721389310737926172758215417020196484', '1.32e+37237312893127', 3, 6);
T('5.779057872258094667008134581095873286949E+276942', '821971.0578422894981036602464110568034833053442167943', '2.5082277510422606903005386816057349e+227638934925', 35, 1);
T('3.234957602079743733006474035023788235177958887897394659', '-8917385.713641765141138', '1.236040142276186053347914741210469e-4546695', 34, 3);
T('7.02382916923175308152153170E+2935424741655375', '8.5993802399008400150513E-12', '6.815835610916e+25242', 13, 4);
T('4.992360311632393008744E+3086933337', '0.0001', '2.1566e+308693', 6, 5);
T('6.33175574926366004561254492162211048268353819200771020473583E+31678683237', '-838.669807517585', '2.81429967929548284753e-26567955173458', 21, 4);
T('8.70225874215683402780940756E+62', '80729124.7080711444650235355788625035401659116582618760164228', '1.4319946760261379737452e+5081061400', 24, 5);
T('7.0466981256E-938730', '4991580.3828584279', '8.49e-4685742020013', 3, 5);
T('3142978.77043261726196393912810183328', '41088944.062978216571996458060150794537', '1.977449501463536791e+266968899', 19, 4);
T('7.54676120374E+4721204', '1.05949476793681840403394142637323547976799178E-7', '3.1638012014247051342236981774577249e+0', 35, 2);
T('6.12931205168748126615477420551556222407086E+8496485', '0.007806963137', '5.64e+66331', 3, 5);
T('1.0843948902129116814921916620289752443365240627E+9512', '-33907.2', '3.1023e-322526480', 5, 0);
T('9.424792591573889182E+490', '-4099.140831646798852227115247941398', '2.06618878689362247935868711217229103793e-2012573', 39, 2);
T('6.984207530842498316856532316482320625731E+533602', '0.276288554778127006', '2.2836346372996936096566e+147428', 23, 2);
T('3.483181455095039283452040339540205257972195888686400E+26426631', '3.267685789226584726885149522992583974395098585', '2.2225028588555440314564e+86353928', 23, 1);
T('8.05914857782984274340134363E+9529107189', '-48391.3590410821', '7.084267e-461126447367713', 7, 2);
T('6.667706928066E+588', '-452.5170626722110964197', '1.269761e-266453', 7, 4);
T('4.332724328638592031920E-1272', '-3688161850.5441308544737539', '1.077950198283015828538227265790897e+4688993396051', 34, 4);
T('6.1617376859265725210397180416710062730E-5421069728', '-0.8428263634667884782729544155177748363', '1.92552637493249732465e+4569020484', 22, 2);
T('8.823870854176516809913632846345369275E+126', '4.5681337680126745060330065921', '8.0306784035745321895873846e+579', 26, 4);
T('2.71269199514602030323862288735145483185608E+88', '2E+8', '1.47e+17686680097', 4, 4);
T('5.5161565686281122715834E+6331061611', '-754.412710', '1.05712032e-4776233347691', 9, 6);
T('9.167647569590782957204307987E-7966144', '953808710.07', '1.857605906e-7598176615061895', 10, 4);
T('5.799224270469984081554282686780313101902709269294E+42260775', '31511.7399233579970195451821559497902620947403832855778', '4.607304027414982979401670050050960889e+1331710574814', 37, 1);
T('4.01491156462719872348162928188702331740975054711281586E+82509815840', '0.00003374858132834888010760622028046', '1.69935338867032322e+2784589', 18, 5);
T('5.19696486681769574E+49241', '-666448.55425180880471347285028388012', '4.78654807854090869049280289299423992209e-32817070271', 39, 3);
T('3.93691591310570876222209441E+40', '-9', '4.40143963e-366', 9, 4);
T('5.518237671457619937E+63684272580474', '56.109398208337743324229394061890135379999', '8.938963858916e+3573286209826181', 13, 3);
T('2.5245648520027399E+7446581', '-3.74E+7', '5.271002629228e-278502144441777', 13, 4);
T('7.148100734428548868905180216007374970E+10091', '4.864513030876098735011320750457324E-24', '1.0000000000000000001130384065693094e+0', 35, 3);
T('9.95999010220284699915062409E+6179384697548', '-27.42041', '2.96928e-169441261954520', 6, 5);
T('7.2771283480237065837295994729772508E-6147', '0.000938847943296114717781947428802302', '1.69711371e-6', 10, 4);
T('2.5450E+759', '400.186591648', '9.4161518551656093608072735032010277773e+303903', 38, 4);
T('8.517633885018893129982210109657784139116033468E+7758', '427876098.083231807', '1.1153261102044912397496e+3319860830180', 23, 5);
T('9.009310089707881947761367141742069784158011344460E+4414175', '0.000039843195815096468919995', '7.496817265e+175', 10, 3);
T('5.1221516955909530159481049707052069694898592704E+167871198063099', '7.30791694823125504372213373845880970619260481225', '1.58989741601315301331379485205e+1226788773445212', 30, 4);
T('4.332357749396665726299774296668661653013893E+4451128041495', '0.8360376887109454344497163848807547689314519966637819352', '3.0856618704315995750894840821781068416e+3721310799968', 38, 2);
T('7.2839831707342784224077681809262551395126924E+5460', '-16.2876373022402746', '2.9e-88945', 2, 2);
T('3.1921424703382660604909862612922056096627445450336127E+836207', '999377.86760665168744001861936', '2.60517991813849285345114e+835687272306', 24, 3);
T('8.73897870319342320249189065619718815609708589924E-4967383903839', '0.002', '2.10805977513587399211543527632122e-9934767808', 33, 4);
T('3.1139E+3300864399', '8.86369001810136687470301975201083181968073341E-7', '6.0797103558826621207e+2925', 20, 6);
T('4.918590346567164486699627', '-248423.71962389186926', '2.3527353740251567790574e-171870', 23, 1);
T('3.9205519934388208215580695857943155E+8915941', '6449.474595653082459432390786755795902600007356025058', '4.164346931e+57503138802', 10, 5);
T('4.32725294084888E+2997', '0.0090772', '1.622e+27', 4, 4);
T('8.3E+564', '459.8865311363357481277718094482503578959', '4.73365540612533132310499740328826e+259798', 33, 3);
T('1.7E+57759', '0.536953655334662805086805650906564308639183506732765554', '1.071319143651107615413264242517e+31014', 31, 5);
T('323407143.061290259662537559899288300420', '6248202428.104243049188010699048136378932850756499005241520', '4.072510400877e+53170638162', 13, 0);
T('8.741219613931E+743', '392862622649.851308039946500457790794257993312643', '4.2673565673396965960084353104e+292266837086573', 29, 3);
T('8.4631487152521732291593145272526509E+63', '365306227.843', '1.42031343759705923e+23353125560', 18, 0);
T('5493464.2906833372361376', '32915291.866333594670366787193548790703', '1.9489025e+221844008', 8, 1);
T('9.020668353903215808077857406600E+67', '3247684.3192414078', '1.5451410009e+220697163', 11, 5);
T('17.619512199789493725271768022603786892208392734063951172102', '359637388.321961668244374588', '1.31937377732e+448105985', 12, 4);
T('6.17496525E+648', '8.11288246466335451135867', '3.6489004770439093845811143302463822646e+5263', 38, 4);
T('2.65E+227', '68812534.5126317899793103608793520', '4.7317514002782e+15649569955', 14, 6);
T('7.898001783187846118998339151722E+71', '467856.67065884345146173301891605718127973847056137', '1.0931344982923e+33637733', 14, 0);
T('5.03038395748731559588822E+81', '78.8205745877353187224629291785274831903152363754602', '5.84986978765280504011809e+6439', 25, 3);
T('3.0726103E+8', '5985077785.80155565434949615849101', '5.162073923251336505739602309652197e+50798392487', 34, 6);
T('2.33815810170913681246375599E+310', '397261.803890310706176724142165845285376018758664303', '5.088348507088e+123297698', 13, 3);
T('3.166063505431573660791571873616714281220803E+96', '6E+9', '3.895413e+579003117730', 7, 6);
T('766146552.23805120368578558067439981875298814670376523100458', '2.15145431661', '1.300741759e+19', 10, 6);
T('8.70676561848294738116092151075445866822E+642', '46089.83178', '7.03139549e+29632989', 9, 0);
T('112443979.653292109323215105791995699369', '78702989.29374789408479740718734', '1.495322924217136843601462602043711039e+633632746', 37, 0);
T('5833.6332988751019', '2.77104587990059415520580017', '2.726403301442541830645721153e+10', 28, 2);
T('986913.0', '604318.05431052875296434876563651088726958209', '8.78082564751224e+3622450', 15, 2);
T('7.8E+875', '61.87765770028567005434837213615321197214594064', '1.4164857555e+54198', 13, 4);
T('8.417935E+503', '2423201.308957811188402584263339484811910910204', '5.612366612e+1221112217', 10, 6);
T('97098.4206704739478399495503794029', '483.55184351117298660225445875', '3.76388962594907060675581e+2411', 25, 3);
T('497289677.247392463', '4819525416.6417041422037675', '1.171409964923356e+41913530255', 16, 6);
T('5376.7501120258018858734264206285201191', '13803900.4929258', '6.843830898606942943e+51495724', 19, 6);
T('1.3881199073641497689499719895200222326007811E+663', '4016037945.0868446114555082015197868386512376648', '1.122846838287516722984900911196468e+2663205149759', 34, 0);
T('47.7103', '4964145.07200376103027028', '1.6568000443171827e+8332874', 18, 2);
T('67073.20320100608142156', '563434121.373694102271224688400635010733838', '5.741909342954012e+2719442421', 16, 5);
T('2.96939005281507291279227198447199431615328065844938260E+807', '0.082881881062284487347703272911262165482279650695', '8.4111149447823787e+66', 17, 2);
T('620406751765.990223068956367065439764694119435459612', '25.5330339049249528399783018544307359273871248', '1.267095359274323814637574519e+301', 28, 3);
T('2.1179809624607662190186814166E+580', '9003426544.3833667', '6.35375586587995e+5224921810997', 15, 0);
T('7404848.862698295261653335262442294330358', '30529203.795799', '1.02321510390145464656213825141861351e+209720860', 36, 5);
T('5.67704115305E+79', '1.24472E+6', '6.1472355e+99271550', 8, 6);
T('514998938916303626693651384036.41606126960', '22591.5037399298384734125', '2.4205832586e+671234', 11, 4);
T('9.0416616156271638054503037985359595E+75', '89106.2291385599405692092507', '7.261515852924155482011e+6768174', 22, 6);
T('7.0805611511944E+42', '1.94492985930272', '2.18965705066357691737147492885176e+83', 33, 1);
T('1.66630944E+74', '6980757669.9081156729942256', '3.74152e+518124090060', 6, 5);
T('5.9E+6', '3456.7700', '1.8971788927235700943477592799711063194e+23405', 38, 0);
T('93720986.7819907489497420190553708041564963922285117', '39.580', '3.3e+315', 2, 1);
T('908948247.896330216349750387912923575076135766138', '11.38907521122213262858256836', '1.0702278292293091784680297675223031e+102', 35, 3);
T('4.485925762349120387154391E+47', '1677945.16766265206929939', '8.53959030215133943e+79957194', 18, 5);
T('2.8448989811706207675566E+89', '2.368592228588521845032068137267440272102614', '7.58940197453762187722508511706932e+211', 33, 5);
*/
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,72 @@
var count = (function powSqrt(Decimal) {
var start = +new Date(),
n, p, pr, r, rm, s, 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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
log('\n Testing pow(0.5) against sqrt()...');
Decimal.config({
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: true
});
for ( ; total < 100000; ) {
// Get a random value in the range [0,1) with a random number of significant digits in the range [1, 40].
r = Decimal.random( 1, Math.random() * 40 + 1 | 0 );
// Change its exponent to a non-zero value of random length in the range (-9e15, 9e15).
r.e = +( ( Math.random() < 0.5 ? '-' : '' ) +
( n = Math.floor( Math.random() * 9e15 ) + '' ).slice( Math.random() * n.length | 0 ) );
// Random rounding mode.
Decimal.rounding = rm = Math.random() * 9 | 0;
// Random precision in the range [1, 30].
Decimal.precision = pr = Math.random() * 30 + 1 | 0;
//log(' r: ' + r);
p = r.pow(0.5);
// sqrt is much faster than pow(0.5)
s = r.sqrt();
//log(' r.pow(0.5): ' + p);
//log(' r.sqrt(): ' + s);
if ( !p.eq(s) ) {
error('\n Test number: ' + total + ' failed');
error(' r: ' + r);
error(' r.pow(0.5): ' + p);
error(' r.sqrt(): ' + s);
error(' precision: ' + pr);
error(' rounding mode: ' + rm + '\n');
process.exit();
} else {
passed++;
}
total++;
if ( total % 1000 == 0 ) log(total);
}
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,130 @@
var count = (function random(Decimal) {
var start = +new Date(),
error, i, j, limit, log, pr, u,
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 (!Decimal && typeof require === 'function') {
Decimal = require('../decimal');
}
function assert(result, r, message) {
total++;
if (result === true) {
passed++;
//log('\n r: ' + r);
} else {
error('\n Test number: ' + total + ' failed');
error(' r: ' + r);
error(' ' + message);
//process.exit();
}
}
function assertException(func, message) {
var actual;
total++;
try {
func();
} catch (e) {
actual = e;
}
if (actual && actual.name == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(limit, pr){
var i, r, d;
if ( !limit ) {
limit = new Decimal(1);
pr = Decimal.precision;
}
for ( i = 0; i < 17; i++ ) {
r = Decimal.random(limit, pr);
//log(r.toString());
d = r.c.length;
if ( pr == null ) {
d = Math.max(d, r.e + 1) - r.e - 1;
assert(d === 0, r, 'dp is not 0: ' + d);
} else {
assert(d <= pr, r, 'sd: ' + d + ' > pr: ' + pr);
}
assert(r.gte(0), r, 'r < 0');
assert(r.lt(limit), r, 'r >= limit: ' + limit);
}
}
log('\n Testing random...');
// First iteration crypto: false, second iteration crypto: true.
Decimal.config({ crypto: false, errors: true });
for ( i = 0; i < 2; i++ ) {
//log( '\n crypto: ' + Decimal.crypto );
Decimal.precision = Math.random() * 100 + 1 | 0;
//log( Decimal.precision );
for ( j = 0; j < 10; j++ ) {
T();
T(u);
T(null);
T(1);
T(1, u);
T(1, null);
T(10);
T(1000);
// limit will have 1 - 17 integer digits and 1 - 17 fraction digits.
limit = +(Math.random() + '').slice(2, Math.random() * 17 + 3 | 0) +
(Math.random() + '').slice(1, Math.random() * 17 + 3 | 0);
if ( +limit == 0 ) {
limit = 1;
}
//log(' limit: ' + limit);
T(limit);
// Precision. Integer 1 - 80.
pr = Math.random() * 80 + 1 | 0;
//log(' pr: ' + pr);
T(limit, pr);
}
Decimal.config({ crypto: true });
}
assertException(function () { Decimal.random(Infinity) }, 'Infinity');
assertException(function () { Decimal.random('-Infinity') }, "'-Infinity'");
assertException(function () { Decimal.random(NaN) }, 'NaN');
assertException(function () { Decimal.random('nanny') }, "'nanny'");
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,809 @@
var count = (function toExponential(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, decimalPlaces){
assert(String(expected), new Decimal(value).toExponential(decimalPlaces));
}
log('\n Testing toExponential...');
Decimal.config({
precision: 20,
rounding: 4,
errors: true,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
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);
Decimal.rounding = 0;
T('1e-8', '0.00000001');
T('1.00000000001e+3', '1000.00000001');
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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 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.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);
Decimal.rounding = 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',new Decimal('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);
assertException(function () {new Decimal('1.23').toExponential(NaN)}, "('1.23').toExponential(NaN)");
assertException(function () {new Decimal('1.23').toExponential('NaN')}, "('1.23').toExponential('NaN')");
assertException(function () {new Decimal('1.23').toExponential([])}, "('1.23').toExponential([])");
assertException(function () {new Decimal('1.23').toExponential({})}, "('1.23').toExponential({})");
assertException(function () {new Decimal('1.23').toExponential('')}, "('1.23').toExponential('')");
assertException(function () {new Decimal('1.23').toExponential(' ')}, "('1.23').toExponential(' ')");
assertException(function () {new Decimal('1.23').toExponential('hello')}, "('1.23').toExponential('hello')");
assertException(function () {new Decimal('1.23').toExponential('\t')}, "('1.23').toExponential('\t')");
assertException(function () {new Decimal('1.23').toExponential(new Date)}, "('1.23').toExponential(new Date)");
assertException(function () {new Decimal('1.23').toExponential(new RegExp)}, "('1.23').toExponential(new RegExp)");
assertException(function () {new Decimal('1.23').toExponential(2.01)}, "('1.23').toExponential(2.01)");
assertException(function () {new Decimal('1.23').toExponential(10.5)}, "('1.23').toExponential(10.5)");
assertException(function () {new Decimal('1.23').toExponential('1.1e1')}, "('1.23').toExponential('1.1e1')");
assertException(function () {new Decimal('1.23').toExponential(true)}, "('1.23').toExponential(true)");
assertException(function () {new Decimal('1.23').toExponential(false)}, "('1.23').toExponential(false)");
assertException(function () {new Decimal('1.23').toExponential(function (){})}, "('1.23').toExponential(function (){})");
assertException(function () {new Decimal(12.3).toExponential('-1')}, ".toExponential('-1')");
assertException(function () {new Decimal(12.3).toExponential(-23)}, ".toExponential(-23)");
assertException(function () {new Decimal(12.3).toExponential(1e9 + 1)}, ".toExponential(1e9 + 1)");
assertException(function () {new Decimal(12.3).toExponential(-0.01)}, ".toExponential(-0.01)");
assertException(function () {new Decimal(12.3).toExponential('-1e-1')}, ".toExponential('-1e-1')");
assertException(function () {new Decimal(12.3).toExponential(Infinity)}, ".toExponential(Infinity)");
assertException(function () {new Decimal(12.3).toExponential('-Infinity')}, ".toExponential('-Infinity')");
Decimal.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', new Decimal(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('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', -0.01);
T('1.23e+2', '12.3e1', '-1e-1');
T('1.23e+2', '12.3e1', Infinity);
T('1.23e+2', '12.3e1', '-Infinity');
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,151 @@
var count = (function toFormat(Decimal) {
var start = +new Date(),
log,
error,
u,
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, sep1, dp, sep2){
assert(String(expected), new Decimal(value).toFormat(sep1, dp, sep2));
}
log('\n Testing toFormat...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
T(0, 0);
T(1, 1);
T(-1, -1);
T(123.456, 123.456);
T(NaN, NaN);
T(Infinity, 1/0);
T(-Infinity, -1/0);
T(0, 0, ' ');
T(1, 1, ' ');
T(-1, -1, ' ');
T(123.456, 123.456, ' ');
T(NaN, NaN, ' ');
T(Infinity, 1/0, ' ');
T(-Infinity, -1/0, ' ');
T('0.0', 0, ' ', 1);
T('1.00', 1, ' ', 2);
T('-1.000', -1, ' ', 3);
T('123.4560', 123.456, ' ', 4);
T(NaN, NaN, ' ', 5);
T(Infinity, 1/0, ' ', 6);
T(-Infinity, -1/0, ' ', 7);
T('9,876.54321', 9876.54321);
T('4,018,736,400,000,000,000,000', '4.0187364e+21');
T('999,999,999,999,999', 999999999999999);
T('99,999,999,999,999', 99999999999999);
T('9,999,999,999,999', 9999999999999);
T('999,999,999,999', 999999999999);
T('99,999,999,999', 99999999999);
T('9,999,999,999', 9999999999);
T('999,999,999', 999999999);
T('99,999,999', 99999999);
T('9,999,999', 9999999);
T('999,999', 999999);
T('99,999', 99999);
T('9,999', 9999);
T('999', 999);
T('99', 99);
T('9', 9);
T('999 999 999 999 999', 999999999999999, ' ', 0, ' ');
T('99 999 999 999 999.0', 99999999999999, ' ', 1, ' ');
T('9 999 999 999 999.00', 9999999999999, ' ', 2, ' ');
T('999 999 999 999.000', 999999999999, ' ', 3, ' ');
T('99 999 999 999.0000', 99999999999, ' ', 4, ' ');
T('9 999 999 999.00000', 9999999999, ' ', 5, ' ');
T('999 999 999.00000 0', 999999999, ' ', 6, ' ');
T('99 999 999.00000 00', 99999999, ' ', 7, ' ');
T('9 999 999.00000 000', 9999999, ' ', 8, ' ');
T('999 999.00000 0000', 999999, ' ', 9, ' ');
T('99 999.00000 00000', 99999, ' ', 10, ' ');
T('9 999.00000 00000 0', 9999, ' ', 11, ' ');
T('999.00000 00000 00', 999, ' ', 12, ' ');
T('99.00000 00000 000', 99, ' ', 13, ' ');
T('9.00000 00000 0000', 9, ' ', 14, ' ');
T('1.00000 00000 00000', 1, ' ', 15, ' ');
T('1.00000 00000 0000', 1, ' ', 14, ' ');
T('1.00000 00000 000', 1, ' ', 13, ' ');
T('1.00000 00000 00', 1, ' ', 12, ' ');
T('1.00000 00000 0', 1, ' ', 11, ' ');
T('1.00000 00000', 1, ' ', 10, ' ');
T('1.00000 0000', 1, ' ', 9, ' ');
T('76,852.342091', '7.6852342091e+4');
T('4 018 736 400 000 000 000 000', '4.0187364e+21', ' ');
T('76 852.342091', '7.6852342091e+4', ' ');
T('76 852.34', '7.6852342091e+4', ' ', 2);
T('76 852.34209 10871 45832 64089', '7.685234209108714583264089e+4', ' ', 20, ' ');
T('76 852.34209 10871 45832 64089 7', '7.6852342091087145832640897e+4', ' ', 21, ' ');
T('76 852.34209 10871 45832 64089 70000', '7.6852342091087145832640897e+4', ' ', 25, ' ');
T('76 852.34', '7.6852342091087145832640897e+4', ' ', 2, ' ');
T('1,234,560,000.00000 00000 08', '1.23456000000000000000789e+9', ',', 12, ' ');
T('1-234-560-000.00000-00000-0789', '1.23456000000000000000789e+9', '-', 14, '-');
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,186 @@
var count = (function toNearest(Decimal) {
var start = +new Date(),
log,
error,
u,
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 isMinusZero(n) {
return n.toString() === '0' && n.s == -1;
}
function T(expected, value, n, pr, rm) {
Decimal.precision = pr;
assert(String(expected), String(new Decimal(value).toNearest(n, rm)));
}
log('\n Testing toNearest...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
T('Infinity', Infinity, u, 20, u);
T('-Infinity', -Infinity, u, 20, u);
T('NaN', NaN, u, 20, u);
T('NaN', NaN, NaN, 20, u);
T('NaN', NaN, Infinity, 20, u);
T('NaN', NaN, -Infinity, 20, u);
T('NaN', NaN, 0, 20, u);
T('NaN', NaN, -0, 20, u);
T('Infinity', '9.999e+9000000000000000', '1e+9000000000000001', 20, u);
T('Infinity', '9.999e+9000000000000000', '-1e+9000000000000001', 20, u);
T('-Infinity', '-9.999e+9000000000000000', '1e+9000000000000001', 20, u);
T('-Infinity', '-9.999e+9000000000000000', '-1e+9000000000000001', 20, u);
T('9.999e+9000000000000000', '9.999e+9000000000000000', u, 20, u);
T('-9.999e+9000000000000000', '-9.999e+9000000000000000', u, 20, u);
T('NaN', 123.456, NaN, 20, u);
T('Infinity', 123.456, Infinity, 20, u);
T('Infinity', 123.456, -Infinity, 20, u);
T('0', 123.456, 0, 20, u);
T('0', 123.456, '-0', 20, u);
T('NaN', -123.456, NaN, 20, u);
T('-Infinity', -123.456, Infinity, 20, u);
T('-Infinity', -123.456, -Infinity, 20, u);
T('0', -123.456, '-0', 20, u);
T('0', 0, 0, 20, u);
T('Infinity', 0, Infinity, 20, u);
T('Infinity', 0, -Infinity, 20, u);
T('-Infinity', -0, Infinity, 20, u);
T('-Infinity', -0, -Infinity, 20, u);
T('0', 1, -3, 20, u);
T('0', -1, -3, 20, u);
T('3', 1.5, -3, 20, 0);
T('0', -1.5, -3, 20, 1);
T('-3', -1.5, -3, 20, 2);
assert(false, isMinusZero(new Decimal(0).toNearest(0)));
assert(true, isMinusZero(new Decimal(-1).toNearest(0)));
assert(true, isMinusZero(new Decimal(-0).toNearest(0)));
assert(false, isMinusZero(new Decimal(1).toNearest(0)));
assert(false, isMinusZero(new Decimal(1).toNearest(-0)));
assert(false, isMinusZero(new Decimal(1).toNearest(-3)));
assert(true, isMinusZero(new Decimal(-1).toNearest(-3)));
T('123', 123.456, u, 20, u);
T('123', 123.456, 1, 20, u);
T('123.5', 123.456, 0.1, 20, u);
T('123.46', 123.456, 0.01, 20, u);
T('123.456', 123.456, 0.001, 20, u);
T('123', 123.456, -1, 20, u);
T('123.5', 123.456, -0.1, 20, u);
T('123.46', 123.456, -0.01, 20, u);
T('123.456', 123.456, -0.001, 20, u);
T('124', 123.456, '-2', 20, u);
T('123.4', 123.456, '-0.2', 20, u);
T('123.46', 123.456, '-0.02', 20, u);
T('123.456', 123.456, '-0.002', 20, u);
T('83105511540', '83105511539.5', 1, 11, 4);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 11, 4);
T('83105511539', '83105511539.5', '1', 11, 5);
T('83105511540', '83105511539.5000000000000000000001', 1, 11, 5);
T('83105511540', '83105511539.5', new Decimal(1), 3, 4);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 3, 4);
T('83105511539', '83105511539.5', new Decimal('1'), 3, 5);
T('83105511540', '83105511539.5000000000000000000001', 1, 3, 5);
T('83105511540', '83105511539.5', Decimal.ONE, 30, 4);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 4);
T('83105511539', '83105511539.5', 1, 30, 5);
T('83105511540', '83105511539.5000000000000000000001', 1, 30, 5);
T('83105511540', '83105511539.5', -1, 11, 4);
T('83105511539', '83105511539.499999999999999999999999999999', -1, 11, 4);
T('83105511539', '83105511539.5', '-1', 11, 5);
T('83105511540', '83105511539.5000000000000000000001', -1, 11, 5);
T('83105511540', '83105511539.5', new Decimal(-1), 3, 4);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 3, 4);
T('83105511539', '83105511539.5', new Decimal('-1'), 3, 5);
T('83105511540', '83105511539.5000000000000000000001', -1, 3, 5);
T('83105511540', '83105511539.5', 1, 30, 0);
T('83105511539', '83105511539.5', 1, 30, 1);
T('83105511540', '83105511539.5', 1, 30, 2);
T('83105511539', '83105511539.5', 1, 30, 3);
T('83105511540', '83105511539.5', 1, 30, 4);
T('83105511539', '83105511539.5', 1, 30, 5);
T('83105511540', '83105511539.5', 1, 30, 6);
T('83105511540', '83105511539.5', 1, 30, 7);
T('83105511539', '83105511539.5', 1, 30, 8);
T('83105511539', '83105511539.499999999999999999999999999999', u, 30, 0);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 1);
T('83105511539', '83105511539.499999999999999999999999999999', u, 30, 2);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 3);
T('83105511539', '83105511539.499999999999999999999999999999', u, 30, 4);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 5);
T('83105511539', '83105511539.499999999999999999999999999999', u, 30, 6);
T('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 7);
T('83105511539', '83105511539.499999999999999999999999999999', u, 30, 8);
T('83105511540', '83105511539.5000000000000000000001', u, 30, 0);
T('83105511540', '83105511539.5000000000000000000001', 1, 30, 1);
T('83105511540', '83105511539.5000000000000000000001', u, 30, 2);
T('83105511540', '83105511539.5000000000000000000001', 1, 30, 3);
T('83105511540', '83105511539.5000000000000000000001', u, 30, 4);
T('83105511540', '83105511539.5000000000000000000001', 1, 30, 5);
T('83105511540', '83105511539.5000000000000000000001', u, 30, 6);
T('83105511540', '83105511539.5000000000000000000001', 1, 30, 7);
T('83105511540', '83105511539.5000000000000000000001', u, 30, 8);
Decimal.rounding = 0;
T('83105511540', '83105511539.5', u, 11, u);
Decimal.rounding = 1;
T('83105511539', '83105511539.5', u, 11, u);
T('3847560', '3847561.00000749', 10, 11, 0);
T('42840000000000000', '42835000000000001', '1e+13', 2, 0);
T('42840000000000000', '42835000000000001', '1e+13', 2, 1);
T('42840000000000000', '42835000000000000.0002', '1e+13', 200, 0);
T('42840000000000000', '42835000000000000.0002', '1e+13', 200, 1);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,92 @@
var count = (function toNumber(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 isMinusZero(n) {
return 1 / n === -Infinity;
}
function T(value, n) {
assert(new Decimal(value).toNumber(), n);
}
log('\n Testing toNumber...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
errors: true
});
assert(false, isMinusZero(new Decimal('0').toNumber()));
assert(false, isMinusZero(new Decimal('0.0').toNumber()));
assert(false, isMinusZero(new Decimal('0.000000000000').toNumber()));
assert(false, isMinusZero(new Decimal('0e+0').toNumber()));
assert(false, isMinusZero(new Decimal('0e-0').toNumber()));
assert(false, isMinusZero(new Decimal('1e-9000000000000000').toNumber()));
assert(true, isMinusZero(new Decimal('-0').toNumber()));
assert(true, isMinusZero(new Decimal('-0.0').toNumber()));
assert(true, isMinusZero(new Decimal('-0.000000000000').toNumber()));
assert(true, isMinusZero(new Decimal('-0e+0').toNumber()));
assert(true, isMinusZero(new Decimal('-0e-0').toNumber()));
assert(true, isMinusZero(new Decimal('-1e-9000000000000000').toNumber()));
T(1, 1);
T('1', 1);
T('1.0', 1);
T('1e+0', 1);
T('1e-0', 1);
T(-1, -1);
T('-1', -1);
T('-1.0', -1);
T('-1e+0', -1);
T('-1e-0', -1);
T(Infinity, 1 / 0);
T('Infinity', 1 / 0);
T(-Infinity, -1 / 0);
T('-Infinity', -1 / 0);
T('9.999999e+9000000000000000', 1 / 0);
T('-9.999999e+9000000000000000', -1 / 0);
T('1e-9000000000000000', 0);
T('-1e-9000000000000000', -0);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

@ -0,0 +1,815 @@
var count = (function toPrecision(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, precision){
assert(String(expected), new Decimal(value).toPrecision(precision));
}
log('\n Testing toPrecision...');
Decimal.config({
precision: 20,
rounding: 4,
errors: true,
toExpNeg: -7,
toExpPos: 40,
minE: -9e15,
maxE: 9e15
});
// ---------------------------------------------------------------- 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
Decimal.rounding = 0;
T('-0.00001', '-0.00001', 1);
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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 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);
Decimal.rounding = 5;
T('-1408003897645960.648499616456', '-1408003897645960.648499616456', 28);
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);
Decimal.rounding = 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', new Decimal(3));
T('123.45', '12.345e1', null);
T('123.45', '12.345e1', undefined);
assertException(function () {new Decimal(1.23).toPrecision(NaN)}, "(1.23).toPrecision(NaN)");
assertException(function () {new Decimal(1.23).toPrecision('NaN')}, "(1.23).toPrecision('NaN')");
assertException(function () {new Decimal(1.23).toPrecision([])}, "(1.23).toPrecision([])");
assertException(function () {new Decimal(1.23).toPrecision({})}, "(1.23).toPrecision({})");
assertException(function () {new Decimal(1.23).toPrecision('')}, "(1.23).toPrecision('')");
assertException(function () {new Decimal(1.23).toPrecision(' ')}, "(1.23).toPrecision(' ')");
assertException(function () {new Decimal(1.23).toPrecision('hello')}, "(1.23).toPrecision('hello')");
assertException(function () {new Decimal(1.23).toPrecision('\t')}, "(1.23).toPrecision('\t')");
assertException(function () {new Decimal(1.23).toPrecision(new Date)}, "(1.23).toPrecision(new Date)");
assertException(function () {new Decimal(1.23).toPrecision(new RegExp)}, "(1.23).toPrecision(new RegExp)");
assertException(function () {new Decimal(1.23).toPrecision(2.01)}, "(1.23).toPrecision(2.01)");
assertException(function () {new Decimal(1.23).toPrecision(10.5)}, "(1.23).toPrecision(10.5)");
assertException(function () {new Decimal(1.23).toPrecision('1.1e1')}, "(1.23).toPrecision('1.1e1')");
assertException(function () {new Decimal(1.23).toPrecision(true)}, "(1.23).toPrecision(true)");
assertException(function () {new Decimal(1.23).toPrecision(false)}, "(1.23).toPrecision(false)");
assertException(function () {new Decimal(1.23).toPrecision(function (){})}, "(1.23).toPrecision(function (){})");
assertException(function () {new Decimal('12.345e1').toPrecision('-1')}, ".toPrecision('-1')");
assertException(function () {new Decimal('12.345e1').toPrecision(-23)}, ".toPrecision(-23)");
assertException(function () {new Decimal('12.345e1').toPrecision(1e9 + 1)}, ".toPrecision(1e9 + 1)");
assertException(function () {new Decimal('12.345e1').toPrecision(0)}, ".toPrecision(0)");
assertException(function () {new Decimal('12.345e1').toPrecision('-0')}, ".toPrecision('-0')");
assertException(function () {new Decimal('12.345e1').toPrecision(0.9)}, ".toPrecision(0.9)");
assertException(function () {new Decimal('12.345e1').toPrecision('-1e-1')}, ".toPrecision('-1e-1')");
assertException(function () {new Decimal('12.345e1').toPrecision(Infinity)}, ".toPrecision(Infinity)");
assertException(function () {new Decimal('12.345e1').toPrecision('-Infinity')}, ".toPrecision('-Infinity')");
Decimal.errors = false;
T('123', '12.345e1', new Decimal(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', 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.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,214 @@
var count = (function trunc(Decimal) {
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 (!Decimal && typeof require === 'function') Decimal = require('../decimal');
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 == 'Decimal Error') {
passed++;
//log('\n Expected and actual: ' + actual);
} else {
error('\n Test number: ' + total + ' failed');
error('\n Expected: ' + message + ' to raise a Decimal Error.');
error(' Actual: ' + (actual || 'no exception'));
//process.exit();
}
}
function T(expected, value, n) {
assert(String(expected), new Decimal(String(value)).trunc(n).toString());
//assert(String(expected), new Decimal(String(value)).truncated(n).toString());
}
log('\n Testing trunc...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15,
errors: true
});
T('-2075364', '-2075364.364286541923');
T('60593539780450631', '60593539780450631');
T('65937898671515', '65937898671515');
T('-39719494751819198566798', '-39719494751819198566798.578');
T('92627382695288166556', '92627382695288166556.8683774524284866028260448205069');
T('-881574', '-881574');
T('-3633239209', '-3633239209.654526163275621746013315304191073405508491056');
T('-23970335459820625362', '-23970335459820625362');
T('131869457416154038', '131869457416154038');
T('-2685', '-2685');
T('-4542227860', '-4542227860.9511298545226');
T('2416872281', '2416872281.963955669484225137349193306323379254936827');
T('-757684868752087594264588207655', '-757684868752087594264588207655.27838048392835556');
T('-438798503526', '-438798503526.2317623894721299587561697');
T('801625782231888715214665', '801625782231888715214665');
T('-91881984778675238', '-91881984778675238');
T('327765350218284325239839632046', '327765350218284325239839632046.91682741746683081459605386');
T('-7469045007691432294', '-7469045007691432294.362757245');
T('8365540212937142194319515218789', '8365540212937142194319515218789.4106658678537421977827');
T('-14108', '-14108.495051214515');
T('49104501', '49104501.10055989379655329194309526150310568683504206945625');
T('131370406', '131370406.330005158136313262837556068534122953');
T('-689', '-689.6944252229740521128820354989299283');
T('73441822178', '73441822178.572653');
T('-2329', '-2329.42655772223486531483602927572548264457');
T('-834103872107533086', '-834103872107533086');
T('-1501493189970435', '-1501493189970435.74866616700317');
T('70591', '70591.2244675522123484658978887');
T('4446128540401735117', '4446128540401735117.435836700611264749985822486641350492901');
T('-597273', '-597273');
T('729117', '729117');
T('504', '504');
T('-6581532150677269472829', '-6581532150677269472829.38194951340848938896000325718062365494');
T('-131279182164804751', '-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('20962819101135667464733349383', '20962819101135667464733349383.8959025798517496777183');
T('4125789711001606948191', '4125789711001606948191.4707575965791242737346836');
T('-6935501', '-6935501.294727166142750626019282');
T('-1', '-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('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');
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(-0, -0.1);
T(-0, -0.49999999999999994);
T(-0, -0.5);
T(-0, -0.7);
T(1, 1);
T(1, 1.1);
T(1, 1.5);
T(1, 1.7);
T(-1, -1);
T(-1, -1.1);
T(-1, -1.5);
T(-1, -1.7);
Decimal.toExpNeg = -100;
Decimal.toExpPos = 100;
T(-0, -1e-308);
T(-1e308, -1e308);
T('2.1e+308', '2.1e308');
T(-0, '-1e-999');
T(0, '1e-999');
T(0, 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);
assertException(function () {new Decimal('0.6').trunc(0)}, "trunc(0)");
assertException(function () {new Decimal('1.6').trunc(0)}, "trunc(0)");
T('0.6', '0.66', 1);
T('1', '1.66', 1);
T('0.6666', '0.66666', 4);
T('1.666', '1.66666', 4);
T('0.6', '0.6', 1);
T('1', '1.6', 1);
T('0.66', '0.666', 2);
T('1.6', '1.66', 2);
T('0.66666', '0.666666', 5);
T('1.6666', '1.66666', 5);
assert('1', new Decimal('1.9999999999').trunc().toString());
assert('-1', new Decimal('-1.9999999999').trunc().toString());
T('-1', '-1.0', 1);
T('-1', '-1.00001', 1);
T('-1', '-1.010203', 2);
T('-2.99', '-2.999', 3);
T('-0.0001', '-0.000123', 1);
T('-0.000123', '-0.000123', 4);
T('0.010203', '0.010203', 5);
T('0.010203', '0.01020301', 6);
T('-9.999', '-9.999', 6);
T('-9.9999', '-9.999900000001', 6);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');
return [passed, total];
})(this.Decimal);
if (typeof module !== 'undefined' && module.exports) module.exports = count;
Loading…
Cancel
Save