1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00
This commit is contained in:
Michael Mclaughlin 2016-01-25 00:11:32 +00:00
parent bc66aa91a5
commit 8a6f8fe412
122 changed files with 33533 additions and 128882 deletions

View File

@ -1,8 +1,11 @@
language: node_js
node_js:
- "4"
- "4.1"
- "4.0"
- "0.12"
- "0.11"
- "0.10"
- "0.8"
- "0.6"
- iojs
- "iojs"

61
CHANGELOG.md Normal file
View File

@ -0,0 +1,61 @@
####5.0.0
* 25/01/2016
* Added trigonometric functions and `cubeRoot` method.
* Added most of JavaScript's `Math` object methods as Decimal methods.
* Added `toBinary`, `toHexadecimal` and `toOctal` methods.
* Added `isPositive` method.
* Removed the 15 significant digit limit for numbers.
* String values containing whitespace or a plus sign are no longer accepted.
* `valueOf` now returns `'-0'` for minus zero.
* `comparedTo` now returns `NaN` not `null` for comparisons with `NaN`.
* `Decimal.max` and `Decimal.min` no longer accept an array.
* The Decimal constructor and `toString` no longer accept a base argument.
* Binary, hexadecimal and octal prefixes are now recognised for string values.
* Removed `Decimal.errors` configuration property.
* Removed `toFormat`.
* Removed `Decimal.ONE`.
* Renamed `exponential` method to `naturalExponential`.
* Renamed `Decimal.constructor` method to `Decimal.clone`.
* Simplified error handling and amended error messages.
* Refactored the test suite.
* `Decimal.crypto` is now `undefined` by default, and the `crypto` object will be used if available.
* Major internal refactoring.
* Removed *bower.json*.
####4.0.2
* 20/02/2015 Add bower.json. Add source map. Amend travis CI. Amend doc/comments.
####4.0.1
* 11/12/2014 Assign correct constructor when duplicating a Decimal.
####4.0.0
* 10/11/2014 `toFormat` amended to use `Decimal.format` object for more flexible configuration.
####3.0.1
* 8/06/2014 Surround crypto require in try catch. See issue #5
####3.0.0
* 4/06/2014 `random` simplified. Major internal changes mean the properties of a Decimal must now be considered read-only
####2.1.0
* 4/06/2014 Amend UMD
####2.0.3
* 8/05/2014 Fix NaN toNumber
####2.0.2
* 30/04/2014 Correct doc links
####2.0.1
* 10/04/2014 Update npmignore
####2.0.0
* 10/04/2014 Add `toSignificantDigits`
* Remove `toInteger`
* No arguments to `ceil`, `floor`, `round` and `trunc`
####1.0.1
* 07/04/2014 Minor documentation clean-up
####1.0.0
* 02/04/2014 Initial release

View File

@ -1,6 +1,6 @@
The MIT Expat Licence.
Copyright (c) 2014 Michael Mclaughlin
Copyright (c) 2016 Michael Mclaughlin
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

151
README.md
View File

@ -6,12 +6,11 @@ An arbitrary-precision Decimal type for JavaScript.
## Features
- Integers and floats
- Simple but full-featured API
- Replicates many of the methods of JavaScript's `Number.prototype` and `Math` objects
- Also handles hexadecimal, binary and octal values
- 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
- Works with numbers with or without fraction digits in bases from 2 to 64 inclusive
- No dependencies
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
- Comprehensive [documentation](http://mikemcl.github.io/decimal.js/) and test set
@ -24,7 +23,7 @@ precision is specified in terms of significant digits instead of decimal places,
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.
This library also adds the trigonometric 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. This is, however, a significantly larger library than
@ -34,13 +33,15 @@ Another major difference is that this library enables multiple Decimal construct
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
It can be loaded using a script tag in an HTML document for the browser
<script src='./relative/path/to/decimal.js'></script>
<script src='path/to/decimal.js'></script>
or as a CommonJS, [Node.js](http://nodejs.org) or AMD module using `require`.
or as a [Node.js](http://nodejs.org) module using `require`.
For Node, the library is also available from the [npm](https://npmjs.org/) registry
var Decimal = require('decimal');
For Node, the library is available from the [npm](https://npmjs.org/) registry
$ npm install decimal.js
@ -55,20 +56,23 @@ To load with AMD loader libraries such as [requireJS](http://requirejs.org/):
*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.
The library exports a single function object, `Decimal`, the constructor of Decimal instances.
It accepts a value of type number *(up to 15 significant digits only)*, string or Decimal.
It accepts a value of type number, 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.
A value can also be in binary, hexadecimal or octal if the appropriate prefix is included.
x = new Decimal(1011, 2) // '11'
y = new Decimal('zz.9', 36) // '1295.25'
z = x.plus(y) // '1306.25'
x = new Decimal('0xff.f') // '255.9375'
y = new Decimal('1b10101100') // '172'
z = x.plus(y) // '427.9375'
z.toBinary() // '0b110101011.1111'
z.toBinary(13) // '0b1.101010111111p+8'
A Decimal is immutable in the sense that it is not changed by its methods.
@ -87,35 +91,31 @@ 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
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`.
and many of the methods of JavaScript's Math object are also replicated.
x.toString(16) // 'ff.8'
Decimal.sqrt('6.98372465832e+9823') // '8.3568682281821340204e+4911'
Decimal.pow(2, 0.0979843) // '1.0702770511687781839'
There is a `toFormat` method,
There are `isNaN` and `isFinite` methods, as `NaN` and `Infinity` are valid `Decimal` values,
y = new Decimal(1e6)
y.toFormat(2) // '1,000,000.00'
x = new Decimal(NaN) // 'NaN'
y = new Decimal(Infinity) // 'Infinity'
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
a `toFraction` method with an optional *maximum denominator* argument
and a `toFraction` method with an optional *maximum denominator* argument
z = new Decimal(355)
pi = z.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
All calculations are rounded according to the number of significant digits and rounding mode
specified by the `precision` and `rounding` properties of the Decimal constructor.
@ -126,7 +126,7 @@ As mentioned above, multiple Decimal constructors can be created, each with thei
Decimal.config({ precision: 5, rounding: 4 })
// Create another Decimal constructor, optionally passing in a configuration object
Decimal10 = Decimal.constructor({ precision: 10, rounding: 1 })
Decimal10 = Decimal.clone({ precision: 10, rounding: 1 })
x = new Decimal(5)
y = new Decimal10(5)
@ -134,18 +134,10 @@ As mentioned above, multiple Decimal constructors can be created, each with thei
x.div(3) // '1.6667'
y.div(3) // '1.666666666'
Decimal.precision // 5
Decimal10.precision // 10
Many of the methods of JavaScript's Math object are also replicated
Decimal.sqrt('6.98372465832e+9823') // '8.3568682281821340204e+4911'
Decimal.pow(2, 0.0979843) // '1.0702770511687781839'
The value of a Decimal is stored in a floating point format in terms of a coefficient, exponent and sign.
The value of a Decimal is stored in a floating point format in terms of its digits, exponent and sign.
x = new Decimal(-12345.67);
x.c // [ 12345, 6700000 ] coefficient (base 10000)
x.d // [ 12345, 6700000 ] digits (base 10000)
x.e // 4 exponent (base 10)
x.s // -1 sign
@ -153,23 +145,21 @@ For further information see the [API](http://mikemcl.github.io/decimal.js/) refe
## Test
The *test* directory contains the test scripts for each method.
The library can be tested using Node.js or a browser.
The tests can be run with Node or a browser.
The *test* directory contains the file *test.js* which runs all the tests when executed by Node, and the file *test.html* which runs all the tests when opened in 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
To run all the tests, from a command-line at the root directory using npm
$ npm test
For the browser, see *single-test.html* and *every-test.html* in the *test/browser* directory,
or at the *test* directory using Node
$ node test
Each separate test module can also be executed individually, for example, at the *test/modules* directory
$ node toFraction
## Build
@ -182,65 +172,16 @@ then
npm run build
will create *decimal.min.js*.
A source map will also be created in the *doc* directory.
will create *decimal.min.js*, and a source map will also be added to the *doc* directory.
## Feedback
Open an issue, or email
Michael <a href='mailto:M8ch88l@gmail.com'>M8ch88l@gmail.com</a>
<a href='mailto:M8ch88l@gmail.com'>M8ch88l@gmail.com</a>
[Bitcoin](https://bitcoin.org/en/getting-started) donation gratefully received:
**1PjzRBjGJycti49AXTiKsdC4PRCnTbyUyf**
Thank you
BTC 16MjxmTB5EZxY5Uk9xyhfsu4n9gYxEJYkY
## Licence
MIT Expat.
See LICENCE.
## Change Log
####4.0.3
* 2/10/2015 Internal round function bugfix.
####4.0.2
* 20/02/2015 Add bower.json. Add source map. Amend travis CI. Amend doc/comments.
####4.0.1
* 11/12/2014 Assign correct constructor when duplicating a Decimal.
####4.0.0
* 10/11/2014 `toFormat` amended to use `Decimal.format` object for more flexible configuration.
####3.0.1
* 8/06/2014 Surround crypto require in try catch. See issue #5
####3.0.0
* 4/06/2014 `random` simplified. Major internal changes mean the properties of a Decimal must now be considered read-only
####2.1.0
* 4/06/2014 Amend UMD
####2.0.3
* 8/05/2014 Fix NaN toNumber
####2.0.2
* 30/04/2014 Correct doc links
####2.0.1
* 10/04/2014 Update npmignore
####2.0.0
* 10/04/2014 Add `toSignificantDigits`
* Remove `toInteger`
* No arguments to `ceil`, `floor`, `round` and `trunc`
####1.0.1
* 07/04/2014 Minor documentation clean-up
####1.0.0
* 02/04/2014 Initial release
See *LICENCE.md*

View File

@ -1,34 +0,0 @@
{
"name": "decimal.js",
"main": "decimal.js",
"version": "4.0.3",
"homepage": "https://github.com/MikeMcl/decimal.js",
"authors": [
"Michael Mclaughlin <M8ch88l@gmail.com>"
],
"description": "An arbitrary-precision Decimal type for JavaScript",
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"arbitrary",
"precision",
"arithmetic",
"bignumber",
"decimal",
"float",
"biginteger",
"bigdecimal",
"bignum",
"math"
],
"license": "MIT",
"ignore": [
".*",
"*.json",
"test"
]
}

9067
decimal.js

File diff suppressed because it is too large Load Diff

5
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

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "decimal.js",
"description": "An arbitrary-precision Decimal type for JavaScript.",
"version": "4.0.3",
"version": "5.0.0",
"keywords": [
"arbitrary",
"precision",
@ -25,12 +25,9 @@
"name": "Michael Mclaughlin",
"email": "M8ch88l@gmail.com"
},
"engines": {
"node": "*"
},
"license": "MIT",
"scripts": {
"test": "node ./test/every-test.js",
"build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v4.0.3 https://github.com/MikeMcl/decimal.js/LICENCE */\""
"test": "node ./test/test.js",
"build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v5.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

View File

@ -1,90 +0,0 @@
<!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',
'toNearest',
'toNumber',
'toPrecision',
'toSD',
'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>

View File

@ -1,50 +0,0 @@
<!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='../toNearest.js'></script> -->
<!-- <script src='../toNumber.js'></script> -->
<!-- <script src='../toPrecision.js'></script> -->
<!-- <script src='../toSD.js'></script> -->
<!-- <script src='../toStringEtc.js'></script> -->
<!-- <script src='../trunc.js'></script> -->
</body>
</html>

View File

@ -1,246 +0,0 @@
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) {
assert(String(expected), new Decimal(String(value)).ceil().toString());
}
log('\n Testing ceil...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -1e3,
toExpPos: 1e3,
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('11', '10.5');
T('0', '-0.0101');
T('-1', '-1.0101');
T('98743655', '98743654.999999999999999999');
T('-98743654', '-98743654.999999999999999999');
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
assert('2', new Decimal('1.0000000000000000001').ceil().toString());
T('1', '1e-9000000000000000');
T('0', '-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

View File

@ -1,591 +0,0 @@
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
});
assert(true, Decimal.config() === Decimal);
assert(true, Decimal.config(undefined) === Decimal);
assert(true, Decimal.config(null) === Decimal);
// Throw if not an object object.
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;

View File

@ -1,133 +0,0 @@
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).toSD().eq(new D3('123.456789').toSD()));
assert(true, new Decimal(123.456789).round().eq(new D3('123.456789').round()));
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;

10088
test/div.js

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,96 +0,0 @@
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;

View File

@ -1,102 +0,0 @@
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',
'toNearest',
'toNumber',
'toPrecision',
'toSD',
'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' );

View File

@ -1,592 +0,0 @@
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;

View File

@ -1,226 +0,0 @@
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) {
assert(String(expected), new Decimal(String(value)).floor().toString());
}
log('\n Testing floor...');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -1e3,
toExpPos: 1e3,
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.5');
T('-729118', '-729117.001');
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.00000005');
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('7.722e+999999999999999', '7.722e+999999999999999');
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
assert('1', new Decimal('1.9999999999').floor().toString());
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

View File

@ -1,373 +0,0 @@
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(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;

View File

@ -1,620 +0,0 @@
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;

View File

@ -1,453 +0,0 @@
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;

View File

@ -1,559 +0,0 @@
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;

View File

@ -1,160 +0,0 @@
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]);
T(-3, 3, [1, '2', 3, '-1', -2, '-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;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

291
test/modules/Decimal.js Normal file
View File

@ -0,0 +1,291 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('Decimal');
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
maxE: 9e15,
minE: -9e15,
crypto: false,
modulo: 1
});
var t = function (coefficient, exponent, sign, n) {
T.assertDecimal(coefficient, exponent, sign, new Decimal(n));
}
t([0], 0, 1, 0);
t([0], 0, -1, -0);
t([1], 0, -1, -1);
t([10], 1, -1, -10);
t([1], 0, 1, 1);
t([10], 1, 1, 10);
t([100], 2, 1, 100);
t([1000], 3, 1, 1000);
t([10000], 4, 1, 10000);
t([100000], 5, 1, 100000);
t([1000000], 6, 1, 1000000);
t([1], 7, 1, 10000000);
t([10], 8, 1, 100000000);
t([100], 9, 1, 1000000000);
t([1000], 10, 1, 10000000000);
t([10000], 11, 1, 100000000000);
t([100000], 12, 1, 1000000000000);
t([1000000], 13, 1, 10000000000000);
t([1], 14, -1, -100000000000000);
t([10], 15, -1, -1000000000000000);
t([100], 16, -1, -10000000000000000);
t([1000], 17, -1, -100000000000000000);
t([10000], 18, -1, -1000000000000000000);
t([100000], 19, -1, -10000000000000000000);
t([1000000], 20, -1, -100000000000000000000);
t([1000000], -1, 1, 1e-1);
t([100000], -2, -1, -1e-2);
t([10000], -3, 1, 1e-3);
t([1000], -4, -1, -1e-4);
t([100], -5, 1, 1e-5);
t([10], -6, -1, -1e-6);
t([1], -7, 1, 1e-7);
t([1000000], -8, 1, 1e-8);
t([100000], -9, -1, -1e-9);
t([10000], -10, 1, 1e-10);
t([1000], -11, -1, -1e-11);
t([100], -12, 1, 1e-12);
t([10], -13, -1, -1e-13);
t([1], -14, 1, 1e-14);
t([1000000], -15, 1, 1e-15);
t([100000], -16, -1, -1e-16);
t([10000], -17, 1, 1e-17);
t([1000], -18, -1, -1e-18);
t([100], -19, 1, 1e-19);
t([10], -20, -1, -1e-20);
t([1], -21, 1, 1e-21);
t([9], 0, 1, '9');
t([99], 1, -1, '-99');
t([999], 2, 1, '999');
t([9999], 3, -1, '-9999');
t([99999], 4, 1, '99999');
t([999999], 5, -1, '-999999');
t([9999999], 6, 1, '9999999');
t([9, 9999999], 7, -1, '-99999999');
t([99, 9999999], 8, 1, '999999999');
t([999, 9999999], 9, -1, '-9999999999');
t([9999, 9999999], 10, 1, '99999999999');
t([99999, 9999999], 11, -1, '-999999999999');
t([999999, 9999999], 12, 1, '9999999999999');
t([9999999, 9999999], 13, -1, '-99999999999999');
t([9, 9999999, 9999999], 14, 1, '999999999999999');
t([99, 9999999, 9999999], 15, -1, '-9999999999999999');
t([999, 9999999, 9999999], 16, 1, '99999999999999999');
t([9999, 9999999, 9999999], 17, -1, '-999999999999999999');
t([99999, 9999999, 9999999], 18, 1, '9999999999999999999');
t([999999, 9999999, 9999999], 19, -1, '-99999999999999999999');
t([9999999, 9999999, 9999999], 20, 1, '999999999999999999999');
// Test base conversion.
t = function (expected, n) {
T.assertEqual(expected, new Decimal(n).valueOf());
}
function randInt() {
return Math.floor(Math.random() * 0x20000000000000 / Math.pow(10, Math.random() * 16 | 0));
}
// Test random integers against Number.prototype.toString(base).
for (var k, i = 0; i < 127; i++) {
k = randInt();
t(k.toString(), '0b' + k.toString(2));
k = randInt();
t(k.toString(), '0B' + k.toString(2));
k = randInt();
t(k.toString(), '0o' + k.toString(8));
k = randInt();
t(k.toString(), '0O' + k.toString(8));
k = randInt();
t(k.toString(), '0x' + k.toString(16));
k = randInt();
t(k.toString(), '0X' + k.toString(16));
}
// Binary.
t('0', '0b0');
t('0', '0B0');
t('-5', '-0b101');
t('1.5', '0b1.1');
t('-1.5', '-0b1.1');
t('18181', '0b100011100000101.00');
t('-12.5', '-0b1100.10');
t('343872.5', '0b1010011111101000000.10');
t('-328.28125', '-0b101001000.010010');
t('-341919.144535064697265625', '-0b1010011011110011111.0010010100000000010');
t('97.10482025146484375', '0b1100001.000110101101010110000');
t('-120914.40625', '-0b11101100001010010.01101');
t('8080777260861123367657', '0b1101101100000111101001111111010001111010111011001010100101001001011101001');
// Octal.
t('8', '0o10');
t('-8.5', '-0O010.4');
t('-262144.000000059604644775390625', '-0o1000000.00000001');
t('572315667420.390625', '0o10250053005734.31');
// Hex.
t('1', '0x00001');
t('255', '0xff');
t('-15.5', '-0Xf.8');
t('-16777216.00000000023283064365386962890625', '-0x1000000.00000001');
t('325927753012307620476767402981591827744994693483231017778102969592507', '0xc16de7aa5bf90c3755ef4dea45e982b351b6e00cd25a82dcfe0646abb');
// Test parsing.
var tx = function (fn, msg) {
T.assertException(fn, msg);
}
t('NaN', NaN);
t('NaN', 'NaN');
t('NaN', '-NaN');
tx(function () {new Decimal(' NaN')}, "' NaN'");
tx(function () {new Decimal('NaN ')}, "'NaN '");
tx(function () {new Decimal(' NaN ')}, "' NaN '");
tx(function () {new Decimal('+NaN')}, "'+NaN'");
tx(function () {new Decimal(' +NaN')}, "' +NaN'");
tx(function () {new Decimal('.NaN')}, "'.NaN'");
tx(function () {new Decimal('NaN.')}, "'NaN.'");
t('Infinity', Infinity);
t('-Infinity', -Infinity);
t('Infinity', 'Infinity');
t('-Infinity', '-Infinity');
tx(function () {new Decimal(' Infinity')}, "' Infinity '");
tx(function () {new Decimal('Infinity ')}, "'Infinity '");
tx(function () {new Decimal(' Infinity ')}, "' Infinity '");
tx(function () {new Decimal('+Infinity')}, "'+Infinity'");
tx(function () {new Decimal(' +Infinity')}, "' +Infinity'");
tx(function () {new Decimal('.Infinity')}, "'.Infinity'");
tx(function () {new Decimal('Infinity.')}, "'Infinity.'");
t('0', 0);
t('-0', -0);
t('0', '0');
t('-0', '-0');
t('0', '0.');
t('-0', '-0.');
t('0', '0.0');
t('-0', '-0.0');
t('0', '0.00000000');
t('-0', '-0.0000000000000000000000');
tx(function () {new Decimal(' 0')}, "' 0'");
tx(function () {new Decimal('0 ')}, "'0 '");
tx(function () {new Decimal(' 0 ')}, "' 0 '");
tx(function () {new Decimal('0-')}, "'0-'");
tx(function () {new Decimal(' -0')}, "' -0'");
tx(function () {new Decimal('-0 ')}, "'-0 '");
tx(function () {new Decimal('+0')}, "'+0'");
tx(function () {new Decimal(' +0')}, "' +0'");
tx(function () {new Decimal(' .0')}, "' .0'");
tx(function () {new Decimal('0. ')}, "'0. '");
tx(function () {new Decimal('+-0')}, "'+-0'");
tx(function () {new Decimal('-+0')}, "'-+0'");
tx(function () {new Decimal('--0')}, "'--0'");
tx(function () {new Decimal('++0')}, "'++0'");
tx(function () {new Decimal('.-0')}, "'.-0'");
tx(function () {new Decimal('.+0')}, "'.+0'");
tx(function () {new Decimal('0 .')}, "'0 .'");
tx(function () {new Decimal('. 0')}, "'. 0'");
tx(function () {new Decimal('..0')}, "'..0'");
tx(function () {new Decimal('+.-0')}, "'+.-0'");
tx(function () {new Decimal('-.+0')}, "'-.+0'");
tx(function () {new Decimal('+. 0')}, "'+. 0'");
tx(function () {new Decimal('.0.')}, "'.0.'");
t('1', 1);
t('-1', -1);
t('1', '1');
t('-1', '-1');
t('0.1', '.1');
t('0.1', '.1');
t('-0.1', '-.1');
t('1', '1.');
t('1', '1.0');
t('-1', '-1.');
t('-1', '-1.0000');
t('1', '1.00000000');
t('-1', '-1.000000000000000000000000');
tx(function () {new Decimal(' 1')}, "' 1'");
tx(function () {new Decimal('1 ')}, "'1 '");
tx(function () {new Decimal(' 1 ')}, "' 1 '");
tx(function () {new Decimal('1-')}, "'1-'");
tx(function () {new Decimal(' -1')}, "' -1'");
tx(function () {new Decimal('-1 ')}, "'-1 '");
tx(function () {new Decimal('+1')}, "'+1'");
tx(function () {new Decimal(' +1')}, "' +1'");
tx(function () {new Decimal('.1.')}, "'.1.'");
tx(function () {new Decimal('+-1')}, "'+-1'");
tx(function () {new Decimal('-+1')}, "'-+1'");
tx(function () {new Decimal('--1')}, "'--1'");
tx(function () {new Decimal('++1')}, "'++1'");
tx(function () {new Decimal('.-1')}, "'.-1'");
tx(function () {new Decimal('.+1')}, "'.+1'");
tx(function () {new Decimal('1 .')}, "'1 .'");
tx(function () {new Decimal('. 1')}, "'. 1'");
tx(function () {new Decimal('..1')}, "'..1'");
tx(function () {new Decimal('+.-1')}, "'+.-1'");
tx(function () {new Decimal('-.+1')}, "'-.+1'");
tx(function () {new Decimal('+. 1')}, "'+. 1'");
tx(function () {new Decimal('-. 1')}, "'-. 1'");
tx(function () {new Decimal('1..')}, "'1..'");
tx(function () {new Decimal('+1..')}, "'+1..'");
tx(function () {new Decimal('-1..')}, "'-1..'");
tx(function () {new Decimal('-.1.')}, "'-.1.'");
tx(function () {new Decimal('+.1.')}, "'+.1.'");
tx(function () {new Decimal('.-10.')}, "'.-10.'");
tx(function () {new Decimal('.+10.')}, "'.+10.'");
tx(function () {new Decimal('. 10.')}, "'. 10.'");
t('123.456789', 123.456789);
t('-123.456789', -123.456789);
t('123.456789', '123.456789');
t('-123.456789', '-123.456789');
tx(function () {new Decimal(void 0)}, "void 0");
tx(function () {new Decimal('undefined')}, "'undefined'");
tx(function () {new Decimal(null)}, "null");
tx(function () {new Decimal('null')}, "'null'");
tx(function () {new Decimal({})}, "{}");
tx(function () {new Decimal([])}, "[]");
tx(function () {new Decimal(function () {})}, "function () {}");
tx(function () {new Decimal(new Date)}, "new Date");
tx(function () {new Decimal(new RegExp)}, "new RegExp");
tx(function () {new Decimal('')}, "''");
tx(function () {new Decimal(' ')}, "' '");
tx(function () {new Decimal('nan')}, "'nan'");
tx(function () {new Decimal('23e')}, "'23e'");
tx(function () {new Decimal('e4')}, "'e4'");
tx(function () {new Decimal('ff')}, "'ff'");
tx(function () {new Decimal('0xg')}, "'oxg'");
tx(function () {new Decimal('0Xfi')}, "'0Xfi'");
tx(function () {new Decimal('--45')}, "'--45'");
tx(function () {new Decimal('9.99--')}, "'9.99--'");
tx(function () {new Decimal('0 0')}, "'0 0'");
T.stop();
})();

128
test/modules/abs.js Normal file
View File

@ -0,0 +1,128 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('absoluteValue');
function t(expected, value){
T.assertEqual(expected, new Decimal(value).abs().valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
t('0', 0);
t('0', '0');
t('0', -0);
t('0', '-0');
t('1', 1);
t('1', -1);
t('1', '-1');
t('0.5', '0.5');
t('0.5', '-0.5');
t('0.1', 0.1);
t('0.1', -0.1);
t('1.1', 1.1);
t('1.1', -1.1);
t('1.5', '1.5');
t('1.5', '-1.5');
t('0.00001', '-1e-5');
t('9000000000', '-9e9');
t('123456.7891011', '123456.7891011');
t('123456.7891011', -123456.7891011);
t('99', '99');
t('99', -99);
t('999.999', 999.999);
t('999.999', '-999.999');
t('1', new Decimal(-1));
t('1', new Decimal('-1'));
t('0.001', new Decimal(0.001));
t('0.001', new Decimal('-0.001'));
t('Infinity', Infinity);
t('Infinity', -Infinity);
t('Infinity', 'Infinity');
t('Infinity', '-Infinity');
t('NaN', NaN);
t('NaN', -NaN);
t('NaN', 'NaN');
t('NaN', '-NaN');
t('11.121', '11.121');
t('0.023842', '-0.023842');
t('1.19', '-1.19');
t('9.622e-11', '-0.00000000009622');
t('5.09e-10', '-0.000000000509');
t('3838.2', '3838.2');
t('127', '127.0');
t('4.23073', '4.23073');
t('2.5469', '-2.5469');
t('29949', '-29949');
t('277.1', '-277.10');
t('4.97898e-15', '-0.00000000000000497898');
t('53.456', '53.456');
t('100564', '-100564');
t('12431.9', '-12431.9');
t('97633.7', '-97633.7');
t('220', '220');
t('18.72', '18.720');
t('2817', '-2817');
t('44535', '-44535');
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('5.2452468128e+1', '-5.2452468128e+1');
t('1.41525905257189365008396e+16', '1.41525905257189365008396e+16');
t('2.743068083928e+11', '2.743068083928e+11');
t('1.52993064722314247378724599e+26', '-1.52993064722314247378724599e+26');
t('3.7205576746e+10', '3.7205576746e+10');
t('2.663e-10', '-2.663e-10');
t('1.26574209965030360615518e+17', '-1.26574209965030360615518e+17');
t('1.052e+3', '1.052e+3');
t('4.452945872502e+6', '-4.452945872502e+6');
t('2.95732460816619226e+13', '2.95732460816619226e+13');
t('1.1923100194288654481424e+18', '-1.1923100194288654481424e+18');
t('8.99315449050893705e+6', '8.99315449050893705e+6');
t('5.200726538434486963e+8', '5.200726538434486963e+8');
t('1.182618278949368566264898065e+18', '1.182618278949368566264898065e+18');
t('3.815873266712e-20', '-3.815873266712e-20');
t('1.316675370382742615e+6', '-1.316675370382742615e+6');
t('2.1032502e+6', '-2.1032502e+6');
t('1.8e+1', '1.8e+1');
t('1.033525906631680944018544811261e-13', '1.033525906631680944018544811261e-13');
t('1.102361746443461856816e+14', '-1.102361746443461856816e+14');
t('8.595358491143959e+1', '8.595358491143959e+1');
t('1.226806049797304683867e-18', '1.226806049797304683867e-18');
t('5e+0', '-5e+0');
t('1.091168788407093537887970016e+15', '-1.091168788407093537887970016e+15');
t('3.87166413612272027e+12', '3.87166413612272027e+12');
t('1.411514e+5', '1.411514e+5');
t('1.0053454672509859631996e+22', '1.0053454672509859631996e+22');
t('6.9265714e+0', '6.9265714e+0');
t('1.04627709e+4', '1.04627709e+4');
t('2.285650225267766689304972e+5', '2.285650225267766689304972e+5');
t('4.5790517211306242e+7', '4.5790517211306242e+7');
t('3.0033340092338313923473428e+16', '-3.0033340092338313923473428e+16');
t('2.83879929283797623e+1', '-2.83879929283797623e+1');
t('4.5266377717178121183759377414e-5', '4.5266377717178121183759377414e-5');
t('5.3781e+4', '-5.3781e+4');
t('6.722035208213298413522819127e-18', '-6.722035208213298413522819127e-18');
t('3.02865707828281230987116e+23', '-3.02865707828281230987116e+23');
t('1e-9000000000000000', '1e-9000000000000000');
t('1e-9000000000000000', '-1e-9000000000000000');
t('0e+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.stop();
})();

1008
test/modules/acos.js Normal file

File diff suppressed because it is too large Load Diff

1028
test/modules/acosh.js Normal file

File diff suppressed because it is too large Load Diff

1028
test/modules/asin.js Normal file

File diff suppressed because it is too large Load Diff

1028
test/modules/asinh.js Normal file

File diff suppressed because it is too large Load Diff

1028
test/modules/atan.js Normal file

File diff suppressed because it is too large Load Diff

1059
test/modules/atan2.js Normal file

File diff suppressed because it is too large Load Diff

1027
test/modules/atanh.js Normal file

File diff suppressed because it is too large Load Diff

1018
test/modules/cbrt.js Normal file

File diff suppressed because it is too large Load Diff

75
test/modules/ceil.js Normal file
View File

@ -0,0 +1,75 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('ceil');
function t(expected, n) {
T.assertEqual(expected, Decimal.ceil(n).valueOf());
T.assertEqual(expected, new Decimal(n).ceil().valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -100,
toExpPos: 100,
minE: -9e15,
maxE: 9e15
});
t('0', 0);
t('-0', -0);
t('Infinity', Infinity);
t('-Infinity', -Infinity);
t('NaN', NaN);
t('1', 0.1);
t('1', '0.4999999999999999');
t('1', 0.5);
t('1', 0.7);
t('-0', -0.1);
t('-0', '-0.4999999999999999');
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);
t('-0', '-0.999');
t('2', '1.0000000000000000001');
t('2', '1.0000000000000000000000000000000000000000000000000000000000000000000000000000001');
t('1', '1e-9000000000000000');
t('-0', '-1e-9000000000000000');
t('-0', '-9.9e-9000000000000001');
t('9.999999e+9000000000000000', '9.999999e+9000000000000000');
t('-9.999999e+9000000000000000', '-9.999999e+9000000000000000');
t('-Infinity', '-1e+9000000000000001');
t('5.5879983320336874473209567979e+287894365', '5.5879983320336874473209567979e+287894365');
t('-5.5879983320336874473209567979e+287894365', '-5.5879983320336874473209567979e+287894365');
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('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('276312604693909858428', '276312604693909858427.21965306055697011390137926559');
t('1', '0.0000252');
T.stop();
})();

112
test/modules/clone.js Normal file
View File

@ -0,0 +1,112 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('clone');
function t(expression) {
T.assert(expression);
}
Decimal.config({
precision: 10,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
var D1 = Decimal.clone({ precision: 1 });
var D2 = Decimal.clone({ precision: 2 });
var D3 = Decimal.clone({ precision: 3 });
var D4 = Decimal.clone({ precision: 4 });
var D5 = Decimal.clone({ precision: 5 });
var D6 = Decimal.clone({ precision: 6 });
var D7 = Decimal.clone({ precision: 7 });
var D8 = Decimal.clone();
D8.config({ precision: 8 });
var D9 = Decimal.clone({ precision: 9 });
t(Decimal.prototype === D9.prototype);
t(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);
t(x1.div(3).eq(2));
t(x2.div(3).eq(1.7));
t(x3.div(3).eq(1.67));
t(x4.div(3).eq(1.667));
t(x5.div(3).eq(1.6667));
t(x6.div(3).eq(1.66667));
t(x7.div(3).eq(1.666667));
t(x8.div(3).eq(1.6666667));
t(x9.div(3).eq(1.66666667));
t(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);
t(x1.div(y1).eq(2));
t(x2.div(y2).eq(1.7));
t(x3.div(y3).eq(1.67));
t(x4.div(y4).eq(1.667));
t(x5.div(y5).eq(1.6667));
t(x6.div(y6).eq(1.66667));
t(x7.div(y7).eq(1.666667));
t(x8.div(y8).eq(1.6666667));
t(x9.div(y9).eq(1.66666667));
t(x .div(y ).eq(1.666666667));
t(x1.div(y9).eq(2));
t(x2.div(y8).eq(1.7));
t(x3.div(y7).eq(1.67));
t(x4.div(y6).eq(1.667));
t(x5.div(y5).eq(1.6667));
t(x6.div(y4).eq(1.66667));
t(x7.div(y3).eq(1.666667));
t(x8.div(y2).eq(1.6666667));
t(x9.div(y1).eq(1.66666667));
t(Decimal.precision == 10);
t(D9.precision === 9);
t(D8.precision === 8);
t(D7.precision === 7);
t(D6.precision === 6);
t(D5.precision === 5);
t(D4.precision === 4);
t(D3.precision === 3);
t(D2.precision === 2);
t(D1.precision === 1);
t(new Decimal(9.99).eq(new D5('9.99')));
t(!new Decimal(9.99).eq(new D3('-9.99')));
t(!new Decimal(123.456789).toSD().eq(new D3('123.456789').toSD()));
t(new Decimal(123.456789).round().eq(new D3('123.456789').round()));
t(new Decimal(1).constructor === new Decimal(1).constructor);
t(new D9(1).constructor === new D9(1).constructor);
t(new Decimal(1).constructor !== new D1(1).constructor);
t(new D8(1).constructor !== new D9(1).constructor);
T.assertException(function () { Decimal.clone(null) }, "Decimal.clone(null)");
T.stop();
})();

1030
test/modules/cmp.js Normal file

File diff suppressed because it is too large Load Diff

350
test/modules/config.js Normal file
View File

@ -0,0 +1,350 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('config');
var MAX_DIGITS = 1e9;
var EXP_LIMIT = 9e15;
var t = function (actual) {
T.assert(actual);
}
var tx = function (fn, msg) {
T.assertException(fn, msg);
}
/*
precision {number} [1, MAX_DIGITS]
rounding {number} [0, 8]
toExpNeg {number} [-EXP_LIMIT, 0]
toExpPos {number} [0, EXP_LIMIT]
maxE {number} [0, EXP_LIMIT]
minE {number} [-EXP_LIMIT, 0]
modulo {number} [0, 9]
crypto {boolean|number} {true, false, 1, 0}
isExpBin {boolean|number} {true, false, 1, 0}
isExpHex {boolean|number} {true, false, 1, 0}
isExpOct {boolean|number} {true, false, 1, 0}
*/
t(Decimal.config({}) === Decimal);
tx(function () {Decimal.config()}, "config()");
tx(function () {Decimal.config(null)}, "config(null)");
tx(function () {Decimal.config(undefined)}, "config(undefined)");
tx(function () {Decimal.config(0)}, "config(0)");
tx(function () {Decimal.config('')}, "config('')");
tx(function () {Decimal.config('hi')}, "config('hi')");
tx(function () {Decimal.config('123')}, "config('123')");
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15,
crypto: false,
modulo: 1
});
t(Decimal.precision === 20);
t(Decimal.rounding === 4);
t(Decimal.toExpNeg === -7);
t(Decimal.toExpPos === 21);
t(Decimal.minE === -9e15);
t(Decimal.maxE === 9e15);
t(Decimal.crypto === false);
t(Decimal.modulo === 1);
Decimal.config({
precision: 40,
rounding : 4,
toExpNeg: -1000,
toExpPos: 1000,
minE: -1e9,
maxE: 1e9,
crypto: true,
modulo: 4
});
t(Decimal.precision === 40);
t(Decimal.rounding === 4);
t(Decimal.toExpNeg === -1000);
t(Decimal.toExpPos === 1000);
t(Decimal.minE === -1e9);
t(Decimal.maxE === 1e9);
t(Decimal.crypto === true || Decimal.crypto === false);
t(Decimal.modulo === 4);
Decimal.config({
toExpNeg: -7,
toExpPos: 21,
minE: -324,
maxE: 308
});
t(Decimal.toExpNeg === -7);
t(Decimal.toExpPos === 21);
t(Decimal.minE === -324);
t(Decimal.maxE === 308);
// precision
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.precision);
}
t(1, {precision: 1});
t(1, {precision: void 0});
t(20, {precision: 20});
t(300000,{precision: 300000});
t(4e+8, {precision: 4e8});
t(1e9, {precision: 1e9});
t(MAX_DIGITS, {precision: MAX_DIGITS});
tx(function () {Decimal.config({precision: 0})}, "precision: 0");
tx(function () {Decimal.config({precision: MAX_DIGITS + 1})}, "precision: MAX_DIGITS + 1");
tx(function () {Decimal.config({precision: MAX_DIGITS + 0.1})}, "precision: MAX_DIGITS + 0.1");
tx(function () {Decimal.config({precision: '0'})}, "precision: '0'");
tx(function () {Decimal.config({precision: '1'})}, "precision: '1'");
tx(function () {Decimal.config({precision: '123456789'})}, "precision: '123456789'");
tx(function () {Decimal.config({precision: -1})}, "precision: -1");
tx(function () {Decimal.config({precision: 0.1})}, "precision: 0.1");
tx(function () {Decimal.config({precision: 1.1})}, "precision: 1.1");
tx(function () {Decimal.config({precision: -1.1})}, "precision: -1.1");
tx(function () {Decimal.config({precision: 8.1})}, "precision: 8.1");
tx(function () {Decimal.config({precision: 1e+9 + 1})}, "precision: 1e9 + 1");
tx(function () {Decimal.config({precision: []})}, "precision: []");
tx(function () {Decimal.config({precision: {}})}, "precision: {}");
tx(function () {Decimal.config({precision: ''})}, "precision: ''");
tx(function () {Decimal.config({precision: 'hi'})}, "precision: 'hi'");
tx(function () {Decimal.config({precision: '1e+9'})}, "precision: '1e+9'");
tx(function () {Decimal.config({precision: null})}, "precision: null");
tx(function () {Decimal.config({precision: NaN})}, "precision: NaN");
tx(function () {Decimal.config({precision: Infinity})}, "precision: Infinity");
t(MAX_DIGITS, {precision: void 0});
// rounding
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.rounding);
}
t(4, {rounding: void 0});
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});
tx(function () {Decimal.config({rounding: -1})}, "rounding : -1");
tx(function () {Decimal.config({rounding: 0.1})}, "rounding : 0.1");
tx(function () {Decimal.config({rounding: 8.1})}, "rounding : 8.1");
tx(function () {Decimal.config({rounding: 9})}, "rounding : 9");
tx(function () {Decimal.config({rounding: '0'})}, "rounding: '0'");
tx(function () {Decimal.config({rounding: '1'})}, "rounding: '1'");
tx(function () {Decimal.config({rounding: '123456789'})}, "rounding: '123456789'");
tx(function () {Decimal.config({rounding: 1.1})}, "rounding : 1.1");
tx(function () {Decimal.config({rounding: -1.1})}, "rounding : -1.1");
tx(function () {Decimal.config({rounding: 11})}, "rounding : 11");
tx(function () {Decimal.config({rounding: []})}, "rounding : []");
tx(function () {Decimal.config({rounding: {}})}, "rounding : {}");
tx(function () {Decimal.config({rounding: ''})}, "rounding : ''");
tx(function () {Decimal.config({rounding: 'hi'})}, "rounding : 'hi'");
tx(function () {Decimal.config({rounding: null})}, "rounding : null");
tx(function () {Decimal.config({rounding: NaN})}, "rounding : NaN");
tx(function () {Decimal.config({rounding: Infinity})}, "rounding : Infinity");
t(8, {rounding: void 0});
// toExpNeg
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.toExpNeg);
}
t(-7, {toExpNeg: void 0});
t(0, {toExpNeg: 0});
t(-1, {toExpNeg: -1});
t(-999, {toExpNeg: -999});
t(-5675367, {toExpNeg: -5675367});
t(-98770170790791, {toExpNeg: -98770170790791});
t(-EXP_LIMIT, {toExpNeg: -EXP_LIMIT});
tx(function () {Decimal.config({toExpNeg: -EXP_LIMIT - 1})}, "-EXP_LIMIT - 1");
tx(function () {Decimal.config({toExpNeg: '-7'})}, "toExpNeg: '-7'");
tx(function () {Decimal.config({toExpNeg: -0.1})}, "toExpNeg: -0.1");
tx(function () {Decimal.config({toExpNeg: 0.1})}, "toExpNeg: 0.1");
tx(function () {Decimal.config({toExpNeg: 1})}, "toExpNeg: 1");
tx(function () {Decimal.config({toExpNeg: -Infinity})}, "toExpNeg: -Infinity");
tx(function () {Decimal.config({toExpNeg: NaN})}, "toExpNeg: NaN");
tx(function () {Decimal.config({toExpNeg: null})}, "toExpNeg: null");
tx(function () {Decimal.config({toExpNeg: {}})}, "toExpNeg: {}");
t(-EXP_LIMIT, {toExpNeg: void 0});
// toExpPos
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.toExpPos);
}
t(21, {toExpPos: void 0});
t(0, {toExpPos: 0});
t(1, {toExpPos: 1});
t(999, {toExpPos: 999});
t(5675367, {toExpPos: 5675367});
t(98770170790791, {toExpPos: 98770170790791});
t(EXP_LIMIT, {toExpPos: EXP_LIMIT});
tx(function () {Decimal.config({toExpPos: EXP_LIMIT + 1})}, "EXP_LIMIT + 1");
tx(function () {Decimal.config({toExpPos: '21'})}, "toExpPos: '21'");
tx(function () {Decimal.config({toExpPos: -0.1})}, "toExpPos: -0.1");
tx(function () {Decimal.config({toExpPos: 0.1})}, "toExpPos: 0.1");
tx(function () {Decimal.config({toExpPos: -1})}, "toExpPos: -1");
tx(function () {Decimal.config({toExpPos: Infinity})}, "toExpPos: Infinity");
tx(function () {Decimal.config({toExpPos: NaN})}, "toExpPos: NaN");
tx(function () {Decimal.config({toExpPos: null})}, "toExpPos: null");
tx(function () {Decimal.config({toExpPos: {}})}, "toExpPos: {}");
t(EXP_LIMIT, {toExpPos: void 0});
// maxE
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.maxE);
}
t(308, {maxE: void 0});
t(0, {maxE: 0});
t(1, {maxE: 1});
t(999, {maxE: 999});
t(5675367, {maxE: 5675367});
t(98770170790791, {maxE: 98770170790791});
t(EXP_LIMIT, {maxE: EXP_LIMIT});
tx(function () {Decimal.config({maxE: EXP_LIMIT + 1})}, "EXP_LIMIT + 1");
tx(function () {Decimal.config({maxE: '308'})}, "maxE: '308'");
tx(function () {Decimal.config({maxE: -0.1})}, "maxE: -0.1");
tx(function () {Decimal.config({maxE: 0.1})}, "maxE: 0.1");
tx(function () {Decimal.config({maxE: -1})}, "maxE: -1");
tx(function () {Decimal.config({maxE: Infinity})}, "maxE: Infinity");
tx(function () {Decimal.config({maxE: NaN})}, "maxE: NaN");
tx(function () {Decimal.config({maxE: null})}, "maxE: null");
tx(function () {Decimal.config({maxE: {}})}, "maxE: {}");
t(EXP_LIMIT, {maxE: void 0});
// minE
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.minE);
}
t(-324, {minE: void 0});
t(0, {minE: 0});
t(-1, {minE: -1});
t(-999, {minE: -999});
t(-5675367, {minE: -5675367});
t(-98770170790791, {minE: -98770170790791});
t(-EXP_LIMIT, {minE: -EXP_LIMIT});
tx(function () {Decimal.config({minE: -EXP_LIMIT - 1})}, "-EXP_LIMIT - 1");
tx(function () {Decimal.config({minE: '-324'})}, "minE: '-324'");
tx(function () {Decimal.config({minE: -0.1})}, "minE: -0.1");
tx(function () {Decimal.config({minE: 0.1})}, "minE: 0.1");
tx(function () {Decimal.config({minE: 1})}, "minE: 1");
tx(function () {Decimal.config({minE: -Infinity})}, "minE: -Infinity");
tx(function () {Decimal.config({minE: NaN})}, "minE: NaN");
tx(function () {Decimal.config({minE: null})}, "minE: null");
tx(function () {Decimal.config({minE: {}})}, "minE: {}");
t(-EXP_LIMIT, {minE: void 0});
// crypto
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.crypto);
}
// crypto was set true above, but it will have remained false if
// there is no crypto.getRandomValues or crypto.randomBytes.
var cryptoVal = Decimal.crypto;
t(void 0, {crypto: void 0});
t(false, {crypto: 0});
t(cryptoVal, {crypto: 1});
t(false, {crypto: false});
t(cryptoVal, {crypto: true});
tx(function () {Decimal.config({crypto: 'hiya'})}, "crypto: 'hiya'");
tx(function () {Decimal.config({crypto: 'true'})}, "crypto: 'true'");
tx(function () {Decimal.config({crypto: 'false'})}, "crypto: 'false'");
tx(function () {Decimal.config({crypto: '0'})}, "crypto: '0'");
tx(function () {Decimal.config({crypto: '1'})}, "crypto: '1'");
tx(function () {Decimal.config({crypto: -1})}, "crypto: -1");
tx(function () {Decimal.config({crypto: 0.1})}, "crypto: 0.1");
tx(function () {Decimal.config({crypto: 1.1})}, "crypto: 1.1");
tx(function () {Decimal.config({crypto: []})}, "crypto: []");
tx(function () {Decimal.config({crypto: {}})}, "crypto: {}");
tx(function () {Decimal.config({crypto: ''})}, "crypto: ''");
tx(function () {Decimal.config({crypto: NaN})}, "crypto: NaN");
tx(function () {Decimal.config({crypto: Infinity})}, "crypto: Infinity");
t(void 0, {crypto: void 0});
// modulo
t = function (expected, obj) {
Decimal.config(obj);
T.assertEqual(expected, Decimal.modulo);
}
t(4, {modulo: void 0});
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});
tx(function () {Decimal.config({modulo: -1})}, "modulo: -1");
tx(function () {Decimal.config({modulo: 0.1})}, "modulo: 0.1");
tx(function () {Decimal.config({modulo: 9.1})}, "modulo: 9.1");
tx(function () {Decimal.config({modulo: '0'})}, "modulo: '0'");
tx(function () {Decimal.config({modulo: '1'})}, "modulo: '1'");
tx(function () {Decimal.config({modulo: 1.1})}, "modulo: 1.1");
tx(function () {Decimal.config({modulo: -1.1})}, "modulo: -1.1");
tx(function () {Decimal.config({modulo: 10})}, "modulo: 10");
tx(function () {Decimal.config({modulo: -11})}, "modulo: -11");
tx(function () {Decimal.config({modulo: []})}, "modulo: []");
tx(function () {Decimal.config({modulo: {}})}, "modulo: {}");
tx(function () {Decimal.config({modulo: ''})}, "modulo: ''");
tx(function () {Decimal.config({modulo: ' '})}, "modulo: ' '");
tx(function () {Decimal.config({modulo: 'hi'})}, "modulo: 'hi'");
tx(function () {Decimal.config({modulo: null})}, "modulo: null");
tx(function () {Decimal.config({modulo: NaN})}, "modulo: NaN");
tx(function () {Decimal.config({modulo: Infinity})}, "modulo: Infinity");
t(9, {modulo: void 0});
T.stop();
})();

126
test/modules/cos.js Normal file
View File

@ -0,0 +1,126 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('cos');
function t(n, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.cos(n).valueOf());
T.assertEqual(expected, new Decimal(n).cos().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 40, 4, 'NaN');
t('0', 20, 4, '1');
t('-0', 20, 4, '1');
t('Infinity', 40, 4, 'NaN');
t('-Infinity', 40, 4, 'NaN');
t('0.00006', 10, 2, '0.9999999983'); // 0.9999999982000000005399999999352000000041657142...
t('0.000000065', 18, 4, '0.999999999999997888'); // 0.99999999999999788750000000000074377...
t('14044.44444444444', 10, 4, '0.04549771706');
t('5', 8, 5, '0.28366219');
t('6723', 3, 3, '0.999');
t('2.04964', 8, 2, '-0.46075321');
t('476', 6, 1, '0.0486937');
t('5298612.00024', 2, 3, '-0.26');
t('12.5703596425462281326763791506392117455', 8, 4, '0.99999204');
t('2797', 8, 1, '0.55491269');
t('0.3834777777', 3, 4, '0.927');
t('16355.3334', 9, 4, '0.979658167');
t('0.997737586545708065463833973312637902054356957830033', 5, 5, '0.5422');
t('7803700', 4, 2, '-0.9032');
t('841822094288189413002174891207354317', 5, 2, '-0.86017');
t('67942', 8, 3, '-0.33958641');
t('899999929799999999999919999999999999999999999999999999999999999999999999.99999', 7, 5, '-0.8773558');
t('0.00058849862302952064864312588263928354414752285369272291803582192021298679', 10, 6, '0.9999998268');
t('20000000923980793370370313003363533778888888888.7777777777777777', 9, 4, '-0.801329944');
t('49.73807738608', 3, 1, '0.864');
t('88000', 5, 3, '-0.66135');
t('75465048517642702658117738264729233565816440737178306250850477902340698', 7, 2, '0.4233356');
t('0.704', 10, 2, '0.7622592047');
t('0.94828132184399998008581', 6, 5, '0.58308');
t('0.8', 8, 3, '0.6967067');
t('0.002', 6, 2, '0.999999');
t('61688.77777079779777777777777797777777777777777', 1, 4, '0.9');
t('8111', 7, 2, '0.8296971');
t('22.1513', 10, 6, '-0.9872031473');
t('800000000', 8, 2, '-0.98618707');
t('7332769805669601096865534', 4, 0, '0.8803');
t('2116627523999999999999999999', 2, 5, '0.58');
t('16967658790', 8, 4, '0.70645039');
t('2539668340778777961946252621835163455556224034680348035809827426444170650792306', 8, 2, '-0.49939729');
t('36', 7, 1, '-0.1279636');
t('61999992993999.999999999999999999949999999999999994999929999999999992999999999999999999999', 2, 6, '0.99');
t('0.218944155186302719769455371933055277727070161042429', 10, 4, '0.9761273219');
t('20', 2, 3, '0.4');
t('173215504685358227465651988', 10, 4, '-0.671213895');
t('5769000000000.2222222222222222', 10, 3, '0.4282801932');
t('0.5', 3, 1, '0.877');
t('5000000000053', 5, 6, '0.85063');
t('281084', 5, 6, '0.83761');
t('80.6', 9, 2, '0.470085225');
t('447162', 7, 4, '0.9642869');
t('6856.6636666666626606066666', 6, 6, '-0.137265');
t('7.37514', 7, 4, '0.4607514');
t('1.29', 3, 4, '0.277');
t('9', 10, 5, '-0.9111302619');
t('5067', 4, 0, '-0.9254');
t('482222222222.62217863079410578', 3, 1, '-0.997');
t('4.2202926299999999999959999999999999999999999999999999990999999999999999999999', 10, 6, '-0.4724745315');
t('24714170816959', 8, 1, '-0.99806747');
t('31365220956895733422', 5, 3, '0.99149');
t('377469441384376095492196870000863.83493122', 1, 0, '0.8');
t('0.1175', 1, 1, '0.9');
t('223953406565183766798339942076619761', 5, 4, '0.77106');
t('9.4', 7, 0, '-0.9996931');
t('67777777777777733221519976680533200000000000', 7, 4, '0.883886');
t('3', 7, 0, '-0.9899925');
t('99127.77777', 8, 3, '-0.44933878');
t('95555555550.5555555515555555555555555555550055555555555560555555559', 3, 0, '0.0823');
t('1.3830713', 3, 5, '0.187');
t('59', 9, 5, '-0.771080223');
t('1.1', 7, 1, '0.4535961');
t('1090000000000000000000000000000000000050000000.00004', 4, 1, '0.9972');
t('8', 1, 6, '-0.1');
t('43019456219304869332859776', 8, 1, '-0.99906433');
t('0.0000003104573823727508545651739730202238202717472186710001424', 7, 4, '1');
t('81888888888.5555555555555555511111111111111111114304', 8, 6, '0.86581506');
t('848765718488021014558633685913717744363956181398886593', 5, 0, '-0.97123');
t('0.4338', 69, 3, '0.907375081713258312704647471639381401468307894324094984616218937905432');
t('6647167168310148646127', 41, 1, '-0.67876552621688089570465682794229097436017');
t('14', 44, 5, '0.13673721820783359424892887667173824055164518');
t('0.815', 74, 3, '0.68586839345673735262969403373783813324713582642679411838288343756307680681');
t('52666376666220.66', 8, 2, '-0.46217165');
t('0.1', 58, 6, '0.9950041652780257660955619878038702948385762254150840359594');
t('5.481638560270924097', 46, 5, '0.6955963080641265200604938991229596548878269881');
t('616019185645542611168895104511361.514', 73, 0, '-0.9897418432019178091874564214082330932214823767149588163455308944210649199');
t('58872.6729', 27, 5, '0.71551991401684231627099417');
t('0.00000000986995340365791470449236832278868084019660524206930178008', 33, 1, '0.999999999999999951292009904810772');
t('200000000000000000000', 24, 1, '0.167301557725715824849981');
t('8712357290413741268816184846819797318515482698552148280140735653', 57, 0, '-0.279047254515165435013067136950333012052507338721363544685');
t('0.0177165009539797142337288907', 37, 1, '0.9998430669018118198896427823538202954');
t('255555555555555775027123062979747796598651156132669853568621902', 14, 2, '-0.99883756464211');
t('3741565840746605.71876151239588', 15, 0, '-0.930123581114026');
t('3050000000000000000000200000000000000000000.0000000000000000000000008', 41, 3, '-0.33127228153577434134804953378906485886176');
t('0.33482', 27, 4, '0.944469472783453774254728912');
t('0.1979574070039662', 30, 0, '0.980470333633282159348863278164');
t('960492.3601219999999', 74, 6, '0.78272168046024997208016985369610426247753755795663609587331768113997535495');
t('0.1145342', 57, 0, '0.993448125551484394628225244895937689399175688856818869855');
t('99999999999999999999999.99', 70, 0, '-0.7059760628345569635155393670172360201795320597371430862306924466086157');
t('0.10859933721171128209598967066', 80, 4, '0.99410888528803407646108267824473898405842663808987770888683180574685964084716924');
t('2813920.875088303362819', 33, 2, '-0.866254989781355498995879756871368');
t('35999999999999999999999999999999999999999.999999999999999999999999919', 38, 3, '-0.9562598584240982386154988349219959087');
T.stop();
})();

125
test/modules/cosh.js Normal file
View File

@ -0,0 +1,125 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('cosh');
function t(n, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.cosh(n).valueOf());
T.assertEqual(expected, new Decimal(n).cosh().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 40, 4, 'NaN');
t('0', 20, 4, '1');
t('-0', 20, 4, '1');
t('Infinity', 40, 4, 'Infinity');
t('-Infinity', 40, 4, 'Infinity');
t('0.7356369431260767888795717715533948998814', 4, 2, '1.284');
t('0.32350325607614', 8, 2, '1.0527852');
t('0.39', 10, 3, '1.077018834');
t('-0.4085', 1, 3, '1');
t('-0.8353225329554414512103907831003554564', 10, 1, '1.369646055');
t('0.822765764301886756212368544717371789849053470184', 1, 2, '2');
t('-0.608417', 2, 3, '1.1');
t('-0.3135167132332845', 4, 1, '1.049');
t('-0.3872949', 5, 6, '1.0759');
t('-0.69', 5, 2, '1.2477');
t('-0.6767082617749', 8, 6, '1.2378392');
t('-0.8808', 8, 5, '1.4136402');
t('0.49600945701356094984359748395247735156888479861846043140472804537060894678', 6, 5, '1.12556');
t('0.046', 8, 6, '1.0010582');
t('0.9873815', 5, 3, '1.5283');
t('0.8784', 10, 5, '1.411246223');
t('0.7', 7, 3, '1.255169');
t('-0.503676971304', 2, 4, '1.1');
t('-0.52', 9, 0, '1.1382741');
t('0.335', 5, 3, '1.0566');
t('0.54503134222707683066822814099005615624557424312284166822346112986570184867578297341372133058', 8, 4, '1.152243');
t('0.140170026295214447428649742547694034916', 3, 3, '1');
t('0.9749', 8, 1, '1.514066');
t('0.45175', 1, 6, '1');
t('-0.519253467128781061573541633704', 2, 4, '1.1');
t('-0.406127947', 8, 4, '1.0836098');
t('0.9879237062663941347586862695316948803970665245072293680153692819868', 1, 6, '2');
t('0.93872862', 6, 2, '1.47393');
t('-0.3444', 2, 1, '1');
t('0.08916117467145186539045806046188938916876705938558151882', 3, 4, '1');
t('-0.416', 5, 0, '1.0878');
t('0.96395116729510741473428', 7, 2, '1.50171');
t('0.99122709843935', 6, 6, '1.53283');
t('-0.982458257490853554631770530367962387675296749498661808', 4, 2, '1.523');
t('-0.499', 9, 1, '1.12710543');
t('0.2', 10, 4, '1.020066756');
t('0.32898510410686170443107121609290058087988034054', 1, 2, '2');
t('-0.5054805141', 4, 0, '1.131');
t('0.905453421072444252766729099661770268735489121', 5, 2, '1.4388');
t('0.8', 8, 4, '1.3374349');
t('-0.92256', 9, 6, '1.45661127');
t('-0.3', 3, 1, '1.04');
t('-0.8022', 6, 0, '1.3394');
t('0.280279125313444767164013539810445145153395088331', 9, 6, '1.039536');
t('0.922', 9, 0, '1.4560184');
t('-0.3831639', 2, 3, '1');
t('-0.116822455409380771652804478024770757014', 9, 2, '1.00683151');
t('-0.6271139128871161107740496', 6, 6, '1.20317');
t('-0.365006', 6, 4, '1.06736');
t('0.2851921', 4, 0, '1.041');
t('0.8341406563142720368', 9, 6, '1.36854088');
t('0.91', 4, 3, '1.443');
t('-0.578095765576', 3, 2, '1.18');
t('-0.5523113', 1, 2, '2');
t('0.8820775602347211771265107133401152251168847255764663', 3, 1, '1.41');
t('0.6', 6, 6, '1.18547');
t('0.9519214874557153045994771268316705218216663716829234702503703405', 4, 4, '1.488');
t('-0.3218817', 3, 2, '1.06');
t('0.44351821336668159678862896314345092', 3, 4, '1.1');
t('0.3049381299213785', 53, 1, '1.0468550263953477301259281776879206575932575051887101');
t('0.26099', 10, 5, '1.034251653');
t('-0.144401442746890126', 19, 4, '1.010444017455030066');
t('-0.5714572371177476181814955346898484074259146899385956872902543373645059', 73, 5, '1.167773824213016730263000463935976580681778400516250742892039174797873742');
t('-0.86979236712642165283', 49, 1, '1.402726925102945094675128817370785304534247058512');
t('-0.9152145856049272208', 69, 0, '1.44887088581511840041990778954419353285403899090899859306282037305997');
t('0.387335806024227799329046192853758455983606', 5, 2, '1.076');
t('0.388975556466', 66, 5, '1.07660966083264696675091150003451244766269524553188412387790834976');
t('0.33160669064983873525', 31, 6, '1.055487176550956129534144973298');
t('-0.28019', 70, 5, '1.039510693535834131464819444254660971197184738177259681537805828091364');
t('0.0343866155482285230161896002936333091757205795137', 120, 5, '1.0005912779235089895769422420654318600732389756527372429232171774523704748559241986434711131587505267979139253999862614');
t('-0.75527206899549804249272338314789674457252085843936589751993516463961504230583153756146668708760395655590486810061', 106, 2, '1.29903660802276993760774110068399331119553878155671711944963582837840404664230951744751300716828764841588');
t('-0.83084942449681844413114311598350904971957', 93, 6, '1.36547331079818409968059488018604532655176218338970363279898668882713647242007579671435739185');
t('-0.98844124605395210760378949114', 131, 2, '1.5295995535325468391822464280546813045893064120694053640627522765165675183539459515034055077956555297594529493277522750037125717944');
t('-0.229408429422973', 52, 2, '1.026429721818672220645820449684681483193384767884207');
t('-0.8795273546479571', 109, 6, '1.412369739179125250038557346407853960447139468646550916478036613726909366980231455652343138412407973670167567');
t('0.08734', 48, 3, '1.00381656302446278617584212015393654314148839114');
t('-0.62885554240228925749059660488815716811800585603869', 110, 5, '1.2043323206984141503358874585487300913633309056345327254563876032684247394072689488447245272709777045418471248');
t('0.736352757166802915869146657898488678037', 144, 5, '1.28358114765511064759744597771942942566178143747193954192893000446178314298730052934993653082205769261457701471805410675980773447720532092970925');
t('-0.03585', 71, 4, '1.000642680077818347803829459573033542748786958454887675462988399590914');
t('-0.0688528', 140, 6, '1.0023712906116182102872252559253654170023868298415419690478795554725602053890197559688480320707763057478441774639116768661635006893735054584');
t('0.0168267352', 5, 2, '1.0002');
t('-0.29337986744607176495268228205202618529507623296114708105478490669140318050037567584175308798414405821808486964207338344736952978297599188171', 6, 0, '1.04335');
t('0.86878215121864496587492106526718403062818412998115479876941611922436896770420563647660680761', 75, 0, '1.40173390305230312316107861896321531639504128694271018346467019916830918736');
t('0.2', 13, 5, '1.020066755619');
t('0.7186693973416109381775823439368505900019443708610142063266365964635806721', 64, 2, '1.269550877565823873829899249395373137692396168326956113337601496');
t('-0.6081', 33, 3, '1.19066105804760103593649377284751');
t('0.33638979922638509091106475953810395641998150066065089020973699789581749159274904445966819915958672238151012655263653519891140163', 56, 0, '1.0571145964853011640156635194135243640222120068086141542');
t('-0.528693621225218634808351766034027', 14, 0, '1.1430443609004');
t('-0.143173097658174034133478578859895', 139, 6, '1.01026678782935959075629127133465981817550372382865818357596044596268912805753877412874535411755367732759740274249043367842083642626220661');
t('0.2', 26, 6, '1.0200667556190758462955038');
t('-0.888665339961', 143, 6, '1.4215429767257970529790075871798024719315334083688503048535857341028009449476701044589860625229223409387411810670578448660839797632491579578644');
t('-0.8927373765563130228171556137613812', 76, 4, '1.425668910210701385640797102156834965294078876259114606262240531040574444596');
t('0.9', 103, 1, '1.433086385448774387841790401624048341627737841305230594247417192533449635356864305114609711796244033432');
t('-0.833291445811118155331699076307265315671094768698998', 48, 2, '1.36774796193155903463660933986762434999452033326');
t('-0.7', 66, 6, '1.25516900563094301816467474099029711586260477992884178681185039895');
T.stop();
})();

1048
test/modules/div.js Normal file

File diff suppressed because it is too large Load Diff

1021
test/modules/divToInt.js Normal file

File diff suppressed because it is too large Load Diff

73
test/modules/dpSd.js Normal file
View File

@ -0,0 +1,73 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('decimalPlaces and precision');
function t(n, dp, sd, zs) {
T.assertEqual(dp, new Decimal(n).dp());
T.assertEqual(dp, new Decimal(n).decimalPlaces());
T.assertEqual(sd, new Decimal(n).sd(zs));
T.assertEqual(sd, new Decimal(n).precision(zs));
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
t(0, 0, 1);
t(-0, 0, 1);
t(NaN, NaN, NaN);
t(Infinity, NaN, NaN);
t(-Infinity, NaN, NaN);
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, 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);
t('55325252050000000000000000000000.000000004534500000001', 21, 53);
tx(function () {new Decimal(1).precision(null)}, "new Decimal(1).precision(null)");
tx(function () {new Decimal(1).sd(null)}, "new Decimal(1).sd(null)");
tx(function () {new Decimal(1).sd(2)}, "new Decimal(1).sd(2)");
tx(function () {new Decimal(1).sd('3')}, "new Decimal(1).sd('3')");
tx(function () {new Decimal(1).sd({})}, "new Decimal(1).sd({})");
T.stop();
})();

145
test/modules/exp.js Normal file
View File

@ -0,0 +1,145 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('exp');
function t(n, expected, pr, rm) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.exp(n).valueOf());
T.assertEqual(expected, new Decimal(n).exp().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
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);
// Initial exponent estimate incorrect by -1
t('20.72326583694641116', '1000000000.0000000038', 20, 1);
// Initial 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('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);
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);
// Initial exponent estimate incorrect by +1
t('2302585095.29663062096', '9.999998439e+1000000000', 10, 1);
// Initial 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.stop();
})();

129
test/modules/floor.js Normal file
View File

@ -0,0 +1,129 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('floor');
function t(expected, n) {
T.assertEqual(expected, Decimal.floor(n).valueOf());
T.assertEqual(expected, new Decimal(n).floor().valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -1e3,
toExpPos: 1e3,
minE: -9e15,
maxE: 9e15
});
t('0', 0);
t('-0', -0);
t('0', '0.000');
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);
t('1', '1.0000000000000000000000001');
t('0', 0.999999999999);
t('9', '9.999999999999');
t('123456', 123456.789);
t('-2', '-1.0000000000000000000000001');
t('-1', -0.999999999999);
t('-10', '-9.999999999999');
t('-123457', -123456.789);
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.5');
t('-729118', '-729117.001');
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.00000005');
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('7.722e+999999999999999', '7.722e+999999999999999');
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');
t('1', '1.9999999999');
Decimal.toExpNeg = -100;
Decimal.toExpPos = 100;
t('-1', -1e-308);
t('-1e+308', -1e308);
t('2.1e+308', '2.1e308');
t('-1', '-1e-999');
t('0', '1e-999');
t('0', '1e-9000000000000000');
t('-1', '-1e-9000000000000000');
t('-0', '-9.9e-9000000000000001'); // underflow to zero
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');
T.stop();
})();

49
test/modules/fromJSON.js Normal file
View File

@ -0,0 +1,49 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('fromJSON');
Decimal.config({
//crypto: true,
precision: Math.random() * 40 + 1 | 0,
rounding: Math.random() * 9 | 0,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
var e, fromJ, i, r, toJ;
var maxDigits = 100;
for ( i = 0; i < 100000; ) {
// Get a random value in the range [0,1) with a random number of significant digits
// in the range [1, maxDigits], as a string in exponential format.
e = Decimal.random( Math.random() * maxDigits + 1 | 0 ).toExponential();
// Change exponent to a non-zero value of random length in the range (-9e15, 9e15).
r = new Decimal(e.slice(0, e.indexOf('e') + 1) + ( Math.random() < 0.5 ? '-' : '' ) +
( n = Math.floor( Math.random() * 9e15 ) + '' ).slice( Math.random() * n.length | 0 ));
//( n = Math.floor( Math.random() * 40 ) + '' ).slice( Math.random() * n.length | 0 ));
//console.log(r.toString());
toJ = r.toJSON();
//console.log(' toJ: ' + toJ);
fromJ = Decimal.fromJSON(toJ);
//console.log(' fromJ: ' + fromJ);
/*
if (!r.eq(fromJ)) {
console.error(' r: ' + r);
console.error(' toJ: ' + toJ);
console.error(' fromJ: ' + fromJ);
}
*/
T.assert(r.eq(fromJ));
}
T.stop();
})();

124
test/modules/hypot.js Normal file
View File

@ -0,0 +1,124 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('hypot');
function t(a, b, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.hypot(a, b).valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('1', 'NaN', 20, 4, 'NaN');
t('NaN', '1', 20, 4, 'NaN');
t('Infinity', 'NaN', 20, 4, 'Infinity');
t('NaN', '-Infinity', 20, 4, 'Infinity');
t('Infinity', '-9', 20, 4, 'Infinity');
t('9', 'Infinity', 20, 4, 'Infinity');
t('9', '-Infinity', 20, 4, 'Infinity');
t('0', '0', 20, 4, '0');
t('0', '-0', 20, 4, '0');
t('-0', '-0', 20, 4, '0');
t('-73859972487135996812.3348849386076204815086183608621433996131', '-40900275', 92, 4, '73859972487135996812.334896262958542538634842711692934521304033086425417371740907212824629036');
t('87777821928367383886207001990043726894046439498880958101', '13100000', 53, 2, '87777821928367383886207001990043726894046439498880959000');
t('-9068023035566545177890098186515752036653463863403529285431568942304.1209958989782427940509418772899870623734', '2666666666666.6666666666662666666666666666666666666666766666466666666666666666666666666668', 93, 5, '9068023035566545177890098186515752036653463863403529285431568942304.12099589897824279405094188');
t('-19.8731062176484', '-631970.6', 60, 0, '631970.600312467344715323508497215861344293021711284138304041');
t('-1111111111111141067315396649709360127244075372005400124355334298632449424416463580266666666666', '-0.0000000015372402412953773290762250418563358319557966420343267849914304381916024954828959476537495440147246975615343391', 43, 0, '1111111111111141067315396649709360127244076000000000000000000000000000000000000000000000000000');
t('-0.983064721909232202799884070088', '-1888888888888371106396282947223787931710', 20, 4, '1888888888888371106400000000000000000000');
t('861123450449582222', '-3268941330032700177909698138482', 73, 1, '3268941330032700177909698251903.062363755594001549793838456512462423760753');
t('-1.759', '-0.1666933060407184714285777825813947232316520181597980844428', 8, 3, '1.7668807');
t('0.1852451289933636289285652675346736246965605', '-48506.827382527105658688770367877324273166861983575641312454026244237512829473955620223096782936193504746', 48, 2, '48506.8273828808265642535390473175215096921677017');
t('-3000008000000000000000070000000000000000000001000000000000.000000000000002000000000000000000900000000010002', '-802.661566839437264337325468337423185084', 22, 0, '3000008000000000000001000000000000000000000000000000000000');
t('-8', '-5482493793', 53, 2, '5482493793.0000000058367599140481142689669647662254134');
t('4111111111111111.11111111111611110111171111811111111611', '-0.7801745669150266383906952786894096943691775116027', 26, 1, '4111111111111111.1111111111');
t('4649136268549586431953848205459087026588854116776105905', '-0.4538997053719724982993', 76, 4, '4649136268549586431953848205459087026588854116776105905');
t('-711281636404745616773671624856748035918060782119438', '0.6011202051617683354856452418581', 80, 0, '711281636404745616773671624856748035918060782119438.00000000000000000000000000001');
t('-55102601.0381', '-5160591', 93, 5, '55343729.0091054507509667515051408897750996134016431347788775107555545851579689419350413225929');
t('183', '0.6', 22, 3, '183.0009836039139981977');
t('4000000000080000000000000000000000', '0.55', 82, 0, '4000000000080000000000000000000000.000000000000000000000000000000000037812499999244');
t('-0.55', '-9000000.000000000000000000000000000000000000000000000000000000000000000000000000000009', 62, 1, '9000000.0000000168055555555555398651834705075738799986293162621');
t('-0.388099754174217471056249565014913560596333083573199500992', '0.0000363576265205', 75, 0, '0.388099755877229375967849346839104152672911497025034368058113842991365933724');
t('52222222222227378067480110037255168691979179742111111111', '-867069820.333078943531805179108670644728376893549909696519412570032111919516568762799', 7, 2, '52222230000000000000000000000000000000000000000000000000');
t('-8.0898982865397951925970316274645291728205275567128', '-0.0000945902', 28, 6, '8.089898287092787678956284349');
t('-1664553204017852793900913959927482283751', '-933333388888.15884290172642527', 32, 1, '1664553204017852793900913959927400000000');
t('-0.09771882084', '-8', 41, 2, '8.000596788236885020873363221344096704335');
t('-10.11111111545', '-0.306711465294651568375461540673418284608909142237604855', 98, 2, '10.11576195409518993106696772029199668325921193685867908705991646038726063827463162781415087647978');
t('-4437098359999999999993.9999', '-0.2241991', 56, 3, '4437098359999999999993.9999000000000000000000056642012823');
t('901390573372408932467350822015112608121945120543338853670905789705602623427861.103187236210204922562771581943724285507586728737018434159395', '-23333333333333333351020223106390010419253302605986582847591694927992733993338709578970900366475156635422035555555', 18, 0, '23333333333333333400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
t('19999999999999999999999999999999.919999999999999999999', '-95670705629746263190920599520452475212900072593749902459133558626394349560336068069498100861613875411', 24, 6, '95670705629746263190920600000000000000000000000000000000000000000000000000000000000000000000000000000');
t('459.273', '9638369683361034.552409', 63, 5, '9638369683361034.55240900001094229083644388522937457239375956406');
t('19333333333.33313333333333', '-307058050750', 19, 4, '307666092230.143791');
t('-4888.8813611', '61856704783261924843882364363459938129336598998376', 35, 6, '61856704783261924843882364363459938000000000000000');
t('-90316963180999999999997999999999999.99999999999999959999999999999999999999999999999', '-899997034414865629076187032', 24, 0, '90316963181000004484176000000000000');
t('-0.00001175529004148059889839195560772120687431522218537528816456748920635963047412762382567334499074596992570830887179621917584255805343012605460010989845894713567382571024', '59.8600988774488317444932', 22, 1, '59.86009887744998599287');
t('-844444444444445105013379803702088715444444.44444444', '851735648360163016915210118100049528358186144013411569', 13, 2, '851735648360200000000000000000000000000000000000000000');
t('-0.1098958603115877986399807307790849607335424187223724689574921530969578406825061416021390586394788741395795498746592063682753064315701974886', '-52222222222222262283923266176757777', 76, 5, '52222222222222262283923266176757777.00000000000000000000000000000000000011563');
t('-10027999242546642659855555555555', '-703.824', 25, 3, '10027999242546642659855550000000');
t('-17118682794143106193517128.496346472179213795', '19999999999999999997919330.00231406838630646574151545822388888888888888888', 38, 5, '26325829533112365449334045.441841092728');
t('0.465596788868', '-9431769081', 29, 3, '9431769081.0000000000114920312');
t('-587359.66395', '-0.49568003707000085674015751654640980033', 13, 5, '587359.6639502');
t('-0.059956811106228018570509499080322651692489744383276282735', '0.7728191', 54, 5, '0.775141393890713275121528253795513914835075182802874717');
t('2222215171676429123638899593785648371510606061543680191659124444444444.6906517318485520720388589138008481347302123923691909983086306231440651', '788888.888888885011536108582122208072284443333', 80, 6, '2222215171676429123638899593785648371510606061543680191659124444444444.6906517318');
t('70000000000000010000000000006.100000000000004', '-78957772777.77777777777777777777777777777777777777277771777777777777', 1, 0, '80000000000000000000000000000');
t('-41720000000020000000000000000000000000000000000000000700000000000000600000004000000001000000000000060000000000.00080000000000000006', '-46835015.87548144758089751035240583513', 34, 6, '41720000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
t('28666666666666666666666676666666666666666666666666616666666666666666666.6663666666666666666666666666666666666666666666666664666666666666666666', '-7.8461', 56, 4, '28666666666666666666666676666666666666666666666666616667000000000000000');
t('0.6', '-91.5250722217761303', 63, 0, '91.5270388748665715095625471128327141160527733302883072128489811');
t('30000.6', '511111111111145686553087261381.999991267342292294981021024064788686134890483114665388298481703', 51, 2, '511111111111145686553087261381.999991267342292294982');
t('72926343.726877231000712798686463998173070827809981833334964558342793176683041794308836271', '-82222222222221937444', 49, 2, '82222222222221937444.00003234071924617295968730272');
t('-242915822316177763142341053724.3195904798466883740740090079450439', '-299999999999.999999999999999999995999999999999999999999999999990999994', 51, 2, '242915822316177763142341053724.319590665096045830207');
t('-306555555555555555555555055555555555555555555555555555559555555555555555555555555555555555555555555555555595555555555555555555555555555555555555555555525555555555555555555555555555555.5555555555', '0.15666773914679673976142669430328125908359330664846715765297103124831482667541495', 15, 3, '306555555555555000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
t('-5734991.83220402694035812590544522858837047993475498775680667010453187699606727653014592756227908536357219129844096200521', '99399999.699', 55, 0, '99565305.56110721338952690556051338361260372609898394192');
t('-0.585223', '9742275700501', 25, 1, '9742275700501');
t('-817', '2706343113769608709474153626083514693465686442858333333333333333', 54, 2, '2706343113769608709474153626083514693465686442858333340000000000');
t('521999999999199999929999999999999999.99999995999999', '-6777777777777777777777777.777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777770777777775', 54, 2, '521999999999199999930044002175866866.547023411749520706');
t('-4516475899411196.1710280841858351554959449', '0.00362', 26, 2, '4516475899411196.1710280842');
t('79996999999999999999999999999999999999999999999.999999999999999999299999999999999599999999999999999996', '0.000000006393873924327515206665863616080266830154605167288849831012562983901', 32, 3, '79996999999999999999999999999999000000000000000');
t('165014180635256662053.5623866609995456978976014664', '126847933143118145017958510547081.01687771', 82, 2, '126847933143118145017958617879061.6649297630723081683143413440383325550496316428679');
t('4444444444.44444444444444444444444444444444444444444444', '0.0000390055319967605996065972540356157510147289248305250742502606', 19, 5, '4444444444.444444444');
t('-8905370954396883647914407290800692779839518281513035906502493568844696561439275153317671748655256327646885877826948402873397232451', '0.000000002433575166551955655019349462492613256751863629697572595342683572506451544556497587139362820461701547049759568493058791704546964632763776550260691', 95, 6, '8905370954396883647914407290800692779839518281513035906502493568844696561439275153317671748655300000000000000000000000000000000000');
t('700000000', '0.10532749524343436', 67, 4, '700000000.0000000000079242008958969198076099247634079046096355599626');
t('9555555555555555555555555555555555555555.55555555555555555555555555555555555555555', '757773470777777777787727.7777777777777747777', 34, 5, '9555555555555555555555555555555586000000');
t('-0.297233184499378290751031871', '94444444444450932925402136569369568252675313623114112449951937227491', 57, 4, '94444444444450932925402136569369568252675313623114112450000000000000');
t('706.6640602786138076271815698607630793709065809977913853658899180593912800991919896234768331533404376463838897508518404177667748', '589272858', 76, 5, '589272858.0004237205967572977795909916847730224498576503592425079948021269944');
t('141421829337978396523958245492.356577241347882862045', '-0.0000009062726880615943999813266035730355189554501814541380840728', 17, 3, '141421829337978390000000000000');
t('288888418696038361803537630426270.71151743887471708693463333333333333', '-81195599558835246729685688119938533071101', 8, 4, '81195600000000000000000000000000000000000');
t('382666666.66666666666', '-310.351', 17, 2, '382666666.66679252');
t('509146', '27974901', 27, 1, '27979533.8704760590941855702');
t('600075881745331917265194619524368592248337558828411479126381966442789', '-199999999959999999999999999999999999999999999999.9999999999999999999999999999999999999999999999999999', 68, 5, '600075881745331917265194619524368592248337592157529679693993900861880');
t('33333333333333333333933.333', '92675418847792981854934.77651107680859649467120073', 26, 2, '98487787921777255092429.556');
t('-194.04494819612983', '87934613325863285610318426691747541751704168685', 55, 3, '87934613325863285610318426691747541751704168685');
t('-0.00006', '-9108555555555555755555555555555555555555555555.555855555555565555555555585555555', 69, 5, '9108555555555555755555555555555555555555555555.55585555555556555555556');
t('-1867112.3', '-7443151922333351621784797114283077371961143985830384399', 98, 2, '7443151922333351621784797114283077371961143985830384399.0000000000000000000000000000000000000000003');
t('0.640650325', '8337529018416437', 88, 1, '8337529018416437.000000000000000024613577836791740925174427714878489185918199187020262415');
t('-7.0711298394245347979492394379496305607768672891309791', '-92.5549672712666393257898900443199898401181108080123982312500316214214726463524089322636338782070900725995605695513761536504989976346266550486346671844299550305743931825324317787', 26, 5, '92.824688762156584043556536');
t('11.000500000000070000000000000000515', '-928864249591777933822222222', 69, 4, '928864249591777933822222222.000000000000000000000000065139227989011355');
t('8.9929999999999999999999999999', '-94444444444444.7777777777777777777444449232900948624986161628952947337337208243', 100, 0, '94444444444444.77777777777820593447444492177895346249764146644605457433165778719182374051141272166291');
t('-3', '8000000000', 48, 6, '8000000000.00000000056249999999999999998022460938');
t('524224294278833258504244689131128804963', '-0.1964918169532600262422065880715612530725541194753716933743653473301573055', 92, 0, '524224294278833258504244689131128804963.00000000000000000000000000000000000000003682491879045');
t('-5563710.400490441356383129065751744241271474147187007959891690143773431654594134378', '234644300000000000.86356426586528430874003818', 73, 4, '234644300000000000.8636302271381993667815855570906197025798452968278931064');
t('0.005336508972581768759465256138116638362412237071722728683544001', '-2744818576', 62, 5, '2744818576.0000000000000051876521573143355893278038250258951491');
t('6100958683940338086146995110755471006768600255866666666666666666', '95009361293210581532023714', 96, 2, '6100958683940338086146995110755471006768600255866666666666666666.00000000000073978363081733130453');
t('4948457219440599111007826250603151703105812225460181157894774181631869', '-500000000050000000000000000000000000.7000000000600000000000000000000000000000000005', 23, 0, '4948457219440599111007900000000000000000000000000000000000000000000000');
t('0.000000002979', '-9', 43, 1, '9.000000000000000000493024499999999999986495');
t('0.47555305129875312820342601735', '-0.2673085693', 12, 0, '0.545531461807');
t('3290866969805582657729329868.97622844503712282586503', '8996300581562651076861828923126756911315531038131347433298', 26, 5, '8996300581562651076861828900000000000000000000000000000000');
t('-95721335544.654143365002196', '-1822222', 96, 1, '95721335561.9987248947602645712748098096888624484242375216519098735810157428711542690977103766782');
t('0.974893703406145670332688066323452747831483011640048285105884619867888725281346574205291151337004770627960177971', '0.000239596749', 4, 6, '0.9749');
t('-0.00012856579', '-21536540290437517549950.6925', 13, 0, '21536540290440000000000');
t('6300828.297308463126', '-555138043489683551066925156982819307', 3, 4, '555000000000000000000000000000000000');
t('0.4519719010451812700381881242155284703426402593258190987', '92346327717009585478189395590602.34545881237122995324639951758026247635570631069180557087', 55, 4, '92346327717009585478189395590602.3454588123712299532464');
t('69398002688216703269792743800286307271116693445111111111111111', '-211393667179764005100083390018873694', 100, 0, '69398002688216703269792743800286307271116693445111111433074862.06409526630410784634920186057594444197');
t('0.19', '-5288.143883', 42, 3, '5288.14388641329593020355143132324946951485');
T.stop();
})();

615
test/modules/intPow.js Normal file
View File

@ -0,0 +1,615 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('integer pow');
// Highest finite exponent is 100
function t(expected, n, exp) {
T.assertEqual(expected, Decimal.pow(n, exp).valueOf());
T.assertEqual(expected, new Decimal(n).pow(exp).valueOf());
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
// Test the special cases specified by ES 15.8.2.13 (from v8)
t('4', 2, 2);
t('2147483648', 2, 31);
t('0.25', 2, -2);
t('0.0625', 2, -4);
t('1', 1, 100);
t('0', 0, 1000);
t('NaN', 2, NaN);
t('NaN', +0, NaN);
t('NaN', -0, NaN);
t('NaN', Infinity, NaN);
t('NaN', -Infinity, NaN);
t('1', NaN, +0);
t('1', NaN, -0);
t('NaN', NaN, NaN);
t('NaN', NaN, 2.2);
t('NaN', NaN, 1);
t('NaN', NaN, -1);
t('NaN', NaN, -2.2);
t('NaN', NaN, Infinity);
t('NaN', NaN, -Infinity);
t('Infinity', 1.1, Infinity);
t('Infinity', -1.1, Infinity);
t('Infinity', 2, Infinity);
t('Infinity', -2, Infinity);
t('0', 2, -Infinity);
t('0', -2, -Infinity);
t('Infinity', 1/1.1, -Infinity);
t('Infinity', 1/-1.1, -Infinity);
t('Infinity', 1/2, -Infinity);
t('Infinity', 1/-2, -Infinity);
t('NaN', 1, Infinity);
t('NaN', 1, -Infinity);
t('NaN', -1, Infinity);
t('NaN', -1, -Infinity);
t('0', 0.1, Infinity);
t('0', -0.1, Infinity);
t('0', 0.999, Infinity);
t('0', -0.999, Infinity);
t('Infinity', 0.1, -Infinity);
t('Infinity', -0.1, -Infinity);
t('Infinity', 0.999, -Infinity);
t('Infinity', -0.999, -Infinity);
t('Infinity', Infinity, 2);
t('Infinity', 1/Infinity, -2);
t('Infinity', -Infinity, 2);
t('-Infinity', -Infinity, 3);
t('-Infinity', -Infinity, 13);
t('-Infinity', 1/-Infinity, -3);
t('-Infinity', 1/-Infinity, -13);
t('-Infinity', 1/-0, 3);
t('-Infinity', 1/-0, 13);
t('-Infinity', -0, -3);
t('-Infinity', -0, -13);
t('-Infinity', -0, -1);
t('-Infinity', -0, -10000000001);
t('Infinity', 1/-Infinity, -2);
t('Infinity', 1/+0, 1.1);
t('Infinity', 1/+0, 2);
t('Infinity', +0, -1.1);
t('Infinity', +0, -2);
t('Infinity', 1/-0, 2);
t('Infinity', -0, -2);
t('NaN', -0.00001, 1.1);
t('NaN', -0.00001, -1.1);
t('-Infinity', 1/-0, 1);
t('-Infinity', 1/-0, 10000000001);
t('NaN', 2, NaN);
t('Infinity', 1/-0, 0.5);
t('Infinity', -0, -0.5);
t('Infinity', 1/-0, 0.6);
t('Infinity', -0, -0.6);
t('Infinity', Infinity, 0.1);
t('Infinity', 1/Infinity, -0.1);
Decimal.precision = 20;
t('1.9801312458591796501e+301030', 2, 1e6 + 1); // Math.pow( 2, 1e6 + 1) == Infinity
t('5.0501702959901511235e-301031', 2, -1e6 - 1); // Math.pow( 2, -1e6 - 1) == 0
t('-1.9801312458591796501e+301030', -2, 1e6 + 1); // Math.pow(-2, 1e6 + 1) == -Infinity
t('-5.0501702959901511235e-301031', -2, -1e6 - 1); // Math.pow(-2, -1e6 - 1) == -0
t('-1.9801312458591796501e-698971', -0.2, 1e6 + 1); // Math.pow(-0.2, 1e6 + 1) == -0
t('-5.0501702959901511235e+698970', -0.2, -1e6 - 1); // Math.pow(-0.2, -1e6 - 1) == -Infinity
t('1.9801312458591796501e-698971', 0.2, 1e6 + 1); // Math.pow( 0.2, 1e6 + 1) == 0
t('5.0501702959901511235e+698970', 0.2, -1e6 - 1); // Math.pow( 0.2, -1e6 - 1) == Infinity
Decimal.precision = 600;
t('4096', '8', 4);
t('-1.331', '-1.1', 3);
t('5.125696', '-2.264', 2);
t('6.7266e-7', '6.7266E-7', 1);
t('1', '-1', 8);
t('4142779.6499215776', '21.06', 5);
t('731.1616', '-5.2', 4);
t('1', '61818', 0);
t('3.2', '3.2', 1);
t('5.4139923025768140625e-41', '-1.945E-7', 6);
t('1280630.81718016', '5.8', 8);
t('3965.318943552', '15.828', 3);
t('53.721', '53.721', 1);
t('1', '-1.9', 0);
t('4.58357323731267363492522744606954913014016e-39', '-0.0000161306', 8);
t('-8560814308.6108448224', '-96.94', 5);
t('4.4127502627834341562081e-74', '-6.77E-10', 8);
t('79327261142.56790234534719652175488087744161', '23.0371', 8);
t('3.101121e-38', '1.761E-19', 2);
t('1', '-1', 4);
t('6.23201296e-28', '-1.58E-7', 4);
t('-8.50893402176e-19', '-9.476E-7', 3);
t('16', '4', 2);
t('90368789.0625', '-97.5', 4);
t('1', '-112.8', 0);
t('4.122181458338334221291398681640625e+27', '40042.5', 6);
t('5.94467302491009e+21', '1290.0', 7);
t('5.6599836943004175019970957e+25', '141437', 5);
t('9', '3', 2);
t('69.75757441', '1.7', 8);
t('1e-42', '0.0000010', 7);
t('8', '8', 1);
t('-2.5090696333749305038864384e+25', '-664', 9);
t('24794.911296', '5.4', 6);
t('7077398515.1515538432', '93.32', 5);
t('-1.4520042511984659693722813984375e-130', '-2.8295E-19', 7);
t('4', '4', 1);
t('372088627687.312953646321', '781.019', 4);
t('-5.3864523289963490660381317787272961329536e-23', '-0.000658806', 7);
t('-1.8', '-1.8', 1);
t('1', '-5.9', 0);
t('1', '2', 0);
t('-6.4097340625', '-1.45', 5);
t('170859375', '15', 7);
t('595732589817199.440265999920799232', '43.82', 9);
t('1.7080198121677824e+36', '-4200', 10);
t('1', '658.8', 0);
t('136.460505366756569881', '2.269', 6);
t('-1', '-1', 3);
t('236007.159691873761', '-22.041', 4);
t('1', '-1.1', 0);
t('287803125756.085809269657829376', '18.76', 9);
t('4.1069049025e-34', '-2.02655E-17', 2);
t('-8', '-2', 3);
t('-5.0787635527751e-52', '-5.51E-11', 5);
t('-8', '-2', 3);
t('1704883919.2576', '203.2', 4);
t('22106814.0740608', '11.2', 7);
t('3.7481851264119295287828498195966142655968201e+23', '227.71', 10);
t('-3', '-3', 1);
t('5.308416e-54', '4.8E-14', 4);
t('1', '-1', 8);
t('1', '-4.1', 0);
t('398', '398', 1);
t('1', '1.17981E-18', 0);
t('255896509713547.45824', '761.4', 5);
t('16807', '7', 5);
t('1', '232.6', 0);
t('2.67066142562472466573674890357652039841e+30', '-6358.1', 8);
t('390625', '-5', 8);
t('85766121', '21.0', 6);
t('2206809.987903620081317314341735861401', '4.309', 10);
t('6.1917364224e-80', '-1.2E-8', 10);
t('64', '-2', 6);
t('-1', '-1', 7);
t('-39.8778220049', '-2.09', 5);
t('892496818.033068251283537321', '-31.029', 6);
t('1.1289646949223432899980166202016362758071452681629968849e+25', '320.087', 10);
t('1932991.455312009', '124.569', 3);
t('635307227133823.258624', '-293.2', 6);
t('784', '-28', 2);
t('-43361725294765860565.175323475675341312', '-152.02', 9);
t('1589.6036888689492933115234375', '4.36775', 5);
t('1', '-18.4', 0);
t('20832.8532313216810321678408500840248440324096', '3.46612', 8);
t('6.5536', '-1.6', 4);
t('174729381067.247616', '5590.56', 3);
t('-4.084101e-14', '-0.0021', 5);
t('7.46848810699576790739263937619996819197249e+21', '153.93', 10);
t('2.09881105970752e-16', '0.0000059428', 3);
t('23298085122481', '-169', 6);
t('1', '-4.095E-11', 0);
t('30016915.773120638290557721', '17.629', 6);
t('16807', '7', 5);
t('130666515.5580240243056896', '-10.34', 8);
t('-5.97080224872032e-91', '-9.02E-19', 5);
t('-3450.25251', '-5.1', 5);
t('43046721', '-9', 8);
t('1', '1', 1);
t('3545.66529682492339392399', '5.1279', 5);
t('3396.171616714297', '15.0313', 3);
t('4.622674003397519975764019459730496e+33', '-408146', 6);
t('3.24210716131761936e-27', '2.38620E-7', 4);
t('9', '3', 2);
t('14641', '121', 2);
t('62.81386652381601821841', '2.81523', 4);
t('1', '8', 0);
t('4.29981696e-160', '-1.2E-20', 8);
t('1.692652673311521044295612689449216e-7', '-0.14242', 8);
t('1', '-19.5', 0);
t('1', '8621.8', 0);
t('7.907e-7', '7.907E-7', 1);
t('1.61051', '1.1', 5);
t('1.553e-14', '1.553E-14', 1);
t('858461358961485360081', '171171', 4);
t('64', '-2', 6);
t('-2.9', '-2.9', 1);
t('-2.0661046784e-179', '-1.4E-20', 9);
t('39.0625', '-2.5', 4);
t('-391460020121.8781037', '-45.3', 7);
t('-80.1', '-80.1', 1);
t('3.5831808', '1.2', 7);
t('41.08469075197275390625', '-1.45', 10);
t('-128', '-2', 7);
t('-5277043158.170301334052958483', '-12.03', 9);
t('100.31024025', '10.0155', 2);
t('262144', '4', 9);
t('-2.66450474490105494016e-70', '-1.86E-8', 9);
t('1.58541338622748269695158625134808009096449e+21', '-131.83', 10);
t('1.69e-14', '1.3E-7', 2);
t('81', '-3', 4);
t('1.3979045762098993055105649e+25', '327', 10);
t('-2.8334269484119140625e-17', '-0.0145', 9);
t('8455365204.69607', '96.7', 5);
t('4.826809', '-1.3', 6);
t('-4.2027e-14', '-4.2027E-14', 1);
t('-3671885391606530844.02199', '-5163.9', 5);
t('1.4833', '1.4833', 1);
t('1078702060.96', '32843.6', 2);
t('16384', '4', 7);
t('0.000041046707114327285209693732389121', '-0.185729', 6);
t('9.04141586678594150656e-76', '1.73404E-19', 4);
t('7', '7', 1);
t('-5.408864751631992324037382349788164206309e+39', '-25989', 9);
t('3.6213725246884329693766314512921496510839580087890625e-58', '0.00000180255', 10);
t('51.58686976', '-2.68', 4);
t('32562222.2784028467808485507564561204461862636001', '5.6399', 10);
t('1.5269627878770126091369423832739776731492122624e-24', '-0.0041532', 10);
t('2.27128515349184346452713121698128944001e-82', '-6.849E-9', 10);
t('788.12330352545906108118941549114886272', '2.59298', 7);
t('49478904727733663575.051582184770446498259493718971258958961046708278746324459568256251259157238318185790764612200843144821137580796334089638532287323488178607687532035618686192601481827902773410791645057647691925965756808571011539462511641266331263543939501901006735272661302011976870015625991111560481188335365459566760212844848008439578745211448299643484693328447464460429576345111356618402802188681216', '-1.60380', 96);
t('1.17647340482075248419254427344376045314316013640615098803852731448350843468375614975229837000370025634765625e+81', '-1312.5', 26);
t('7.0251816660378376802360594609084621021532608383100803495211258733288152327693358768741786747381360859889479870288549139760601303377485234176e+87', '-2391.76', 26);
t('85.717123455378345835968064', '2.0998', 6);
t('7.8189586726154755713303078223442071754329e+40', '187', 18);
t('9.145283009860369082115124525217171723626500086794105722560960199131059600008740516579605574000306840952542591838726900925804876261491646795282472377021036430500854987560433039755667787412917103148092128371355207976203112911565783359385741850905996481e+41', '-6.4113', 52);
t('2.05766289512932241998482631797034621069017517962263802542480365981262536498089637707776e+86', '26', 61);
t('98190573319064.214163360748608660888346857427032348178060040012159036566957731914573312588336568078808326155328828092023492584783227218123097647282496144318320115860427194595696623235777670393347299594686642872330179664094829207439052010438267983369137644871417464586087393161049', '-1.6293', 66);
t('1.392598192044227355988772015943279484446048049140235246881310663971517522995991944491655264930301742862780134225258915488062891063359354742689683631308848403923615202977361e+171', '109', 84);
t('1.5469996446227372120183605762031536360861258626528255060075983309687394111102266369973688377324297491658050323998067994446097153176237864040180207896595918522219595889946775556217e+64', '13.37', 57);
t('417.53905413413116367045797', '1.3', 23);
t('1.624290817967129588779052613030846258081e+39', '79677', 8);
t('6.613998972307900952958925063693292646912001305426127894831260851822286968476028114198011923029274945784114379928252947652708965396453170282038903005249536e-263', '0.00000908', 52);
t('17179869184', '2', 34);
t('9.7756260861181096053516970094092017016032995016954767790504110039917368643756356818044285001644705953440430468819149794081183248976623767084182482857941562203266736374606395800621259352114936429301555533971456e+141', '131.6', 67);
t('4294967296', '2', 32);
t('131621703842267136', '-6', 22);
t('7.9228162514264337593543950336e+28', '2', 96);
t('-1', '-1', 41);
t('5.0096959237841976223015468271587016074738912992534254294320102857326166341642003475731604090433896328441157235303061782495282575910872792923981113856240569836427242032573810996210128117467500761653330557379347005097932959928243111015057764620250811725789666461853189934772359267843261626881e+197', '140.9', 92);
t('2.404907604760405225358828131112281116032698930082119547604265954848982041717359046106827774346003151904701415424e+111', '32', 74);
t('2.69721605590607563262106870407286853611938890184108047911269431464974473521e+22', '-2.7', 52);
t('18.174', '18.174', 1);
t('1.36891479058588375991326027382088315966463695625337436471480190078368997177499076593800206155688941388250484440597994042813512732765695774566001e+43', '2.7', 100);
t('1.25668660115116491467662710973545031109788152235501170924313646703423681882164573441433515503588152722789494580469301248e+72', '34.2', 47);
t('1.56438420672167084519979701497174364597412396629019101951505612890666817698608365177006994887516584111152450449887451995069033040411213741933147153316594951835865202053237255800944727011696760985308614176976019463960094165747239428884158901702435389388132623055120422260406418255249330452909476806656e+299', '1308', 96);
t('-1.366174308182025187777528918308146941320736787278460889575749404867695325446359807161410602138908197731224033169833047036778978022709170976735608988099868310813030127497812540494011203545816852288666658682985428600019476831917843e+58', '-4.83', 85);
t('2.966806088806219456880539423158152815514806645521282752514016241570099725287916962770395912230014801025390625e+28', '-5.15', 40);
t('8589934592', '2', 33);
t('3.92012913845865034844198476089476040042936801910400390625e+28', '-10.5', 28);
t('6.26204859896956162110746451442214931102399028194694661966016701109504299345041406486245804277657094315831017177064948219797627444240188709011456e+72', '10.6', 71);
t('-7.4010922571797388655581604684527426699437277457499992187268655958229686891933340740793991046504324130585438416249947232728346081088006867719609592595610095069331022367447133421906806310032697675369409918188139600222703781482594772971289070262621142441874895437059567046831661495957273728351051362944953711082346089727330717918651409489163662706555003193741825901442633007312863953564385259087744338361955671878877893732351367361843585968017578125e+364', '-31956.5', 81);
t('6.192736416792149755132475219493405669399778858602560762871794455317449717448580836229845787580888290473782381059983387805505374173265513677435445890655671110840202944429668728225878544903602239e-270', '0.000319', 77);
t('2.321827472731847506187210910989207010589651530892302311791322352855446782760907718473019283821056753242967949096791603718944064726033664384082861996009850744961116407128920163494805886357836270766853975184523023642990429569615539676822828070446559161161124635674389704743948383107212919966543969471039720464085404567773913503635201792672811032312063265454094042341369554833714443413857449688164664657173315113983032808001e+220', '159.83', 100);
t('4.953736650985698001275587761883016173298229503362193331584010106486052779761329981195411366329068322677550960044762649449732919438910119549694010717647780952298320287365138145210431380601324547389442337520392258009e+27', '-2.797', 62);
t('-338678221586896.02233451034424755534030583977124338116841050703894756829829935320421996887', '-2.47', 37);
t('-3.181403788572786716059998378326698266679069780899509454959934125355133265193e-226', '-0.0000057', 43);
t('2.2481244795444847556680083178853571141700204725943661497539185751725919215990484669445118877448657555202573745174750533635052209260608084995835891707958259234271442982681066779696130155696868114346639852814575962457281749995256623713554214237458259176913852401064878760784275382146658972801541462348779288776844691139086889351786721e+179', '229.03', 76);
t('1.09544203269304121665791452848994634135137143229447033238750572549632571476402641497730897157401184093614916314911584167715115647604065370616785146866296916632437569033863034458711783186506727022529378159297811462454675308057682780534190256280910865229376785975491743196806996272790525705427972427376758443312371576466422700240638756574402393677191376501159420836822933903938571935476091044876631814554274289087939783553959776485376e+31', '-2.0436', 100);
t('-18437563379.178327736384102280592359424', '-2.4', 27);
t('-9.9938258857146531850367031e-85', '-0.0000000231', 11);
t('2.45673281757908854552870925433471410070214400334169452520459965621921664416713287959754208329284439619509099451538227140937811535553399003066102795766261859069268099803838998995339331311912275460846260697085073312049264485545427543086425664188963659692922005683716104197951717376e+78', '-6.08', 100);
t('-1.270210714458885172439348525985048001607770314656078008119108251089872343340175575576722621917724609375e+24', '-4.15', 39);
t('1209.5', '1209.5', 1);
t('1220703125', '5.0', 13);
t('2.2282376678496302739664556233420633e-74', '0.000000006553', 9);
t('2.218088039378445352751296336694731578146959285984085545221611060271486214348079661041003283535646898758718143100202167951881147633680620698026648392938984778649e+159', '893', 54);
t('2.10030968607618842407969732186669026418164521383378412734005003194384320968659491239802049483617846390172315534146347011074332799904332281963786542263761412332465321180532568441958976108339460464558490863953503079336356338135760894630619724493454777575270501253639608281424341291617698518141921861556244699796561591915201261004739209197698527393965924844797945393999012105081714167479170123104969e-75', '-0.16053', 94);
t('2.5812157101662325924336748344070521698410946762506012782923924916938485004644329931151074914373301798478548152505612780265485671672098712055026947247254600014458282820627468534250894082132928621697659949721616819635951012296371246281717642419683893063297904005186874144169940879165882368e+286', '25488', 65);
t('-15.625', '-2.5', 3);
t('2.9729685996261878754343622542880008372085710279050331084451543295302017053107644303792930816e+59', '-72.2', 32);
t('8.15730721', '1.3', 8);
t('1027.334860999330573407176938442293022889', '-1.47', 18);
t('1.20109289910050514343148045475506579676136202628631781424931463646123976128634333627993215283736800191296195442718065238702508520055513255346146658609301480565930380776363581062628797012612519067602295957218821773367819208495782017345400726347727499503218384384326417098721424389373157748956399698521853695814977704822352568748499324367082691064737392226159651276162776412093080580234527587890625e+315', '8679.5', 80);
t('-6.00774319642841528092711102659123449286352750007573133369794363392e-33', '-0.22', 49);
t('-4.399348626310072691340857398671747903319767685984244866658805429802943497233040561059795990923598510826890908258017493538766494536483606174431755682553269424176946343755577041745496403493430254087811474250251864009392456889456030217048416123130922140883015639602300329038985615284964386359900403921860549312983015992252637174331659470716194350399038561704290046291e+177', '-81.31', 93);
t('-3.05410827582876268390180635074883196222812916959850956275590047122226930793718597160851022493537771838978253152932907298258251555751167476560688772053768410645587233357374279876239597797393798828125e-247', '-0.000000217485', 37);
t('5.94029530519133658573841651381893916937282220672559984930445801765696530117833330901747112098660456061962952244422396324466169433806822249922825538552986841011e-19', '0.491', 59);
t('6.30523820693302485362185385323378612453984181696300485861970499164041182778517073604560519798249286847423997356860449832519236757706844668669858983416671702949907296869514603475482872905487176008793424936405673085021973514041591620544995041842415714193527926259387876594710020672351902248919941484928131103515625e+217', '-207.5', 94);
t('1.3437482898194084408359108790569717431056936319064040016470306278420649755238589129250716839755182586596297106623509972801915917688676116852207e-198', '0.0047', 85);
t('-7.2125976851811538835264180669311252876757309817127885777282268797579465235996423577991265862898834402822899090972405912847104748143261578733778979456054998346007864343435284069799588577484912513898046820531311312862161018665360468415091050892814436289818311468501837802070896183140379745282036670643116477155731121958797307187300620339307163520531060733946755523082115115646976e+279', '-767.6', 97);
t('-3.6014175419419889979825978713404525121917028354184157603813105843373968813713708575013260529677555144144724689493141661197266911743582631754736205113266715503341523389605232359965730457026715491821102337726896541765297511282920487936650122950956509166185123335946923710632464810273024751e+116', '-23.51', 85);
t('864441744884.215763637320205869663958329635842919446190153261333597518371076208416885489806126587561695103959519298009135858834566699504679568405218950836778578735139166130606578479646072479355927241854902595925015466294859320621226069690609744261681250304', '1.404', 81);
t('2.1740698194376449374483147468467027620784304276072222988616865620688896e+52', '808.4', 18);
t('3.8358611506121121577937e+22', '113', 11);
t('7.708142065054490966774434895299862856570563111111152865942369472254266622057906176e-375', '0.0000000000000002582', 24);
t('1.697054670829812124918589801369405630774787179949418285317226086899030607907838200923128944336540480137932154797404155642362243064347816887752994688507537824596616056930370261936449615792564115353680658971035397858675806419291627327666883921628766762017e+153', '35.3', 99);
t('-4.710128697246244834921603689e+27', '-9', 29);
t('3.2505902718449668133084058626546515621706592677748264541998335302067693284031047914414370910433910917853346703702752017311701370087768406221174636457161634693311184118695477205673579866365261461786447054994132502457715569269165081396243597525386428206972507983546973520886724081775555138991647659604473279e+52', '6.8159', 63);
t('10125003344964.40019736846338763496828575459544161517257186895064610033021488387585533013795387142569984', '1.4', 89);
t('-1.4631650542473900277009650505078819321358806229e+27', '-26.90', 19);
t('0.000005295825289418576524939548312590198218162176', '0.468', 16);
t('-2.13825209215512828440269455240169347772084407562319954177735966744864590012014618496355742013223900851293500036195697397558882293948621657334016332630442341312358031641684225772703692879077286212410249112292259617578818732032e+224', '-203479518', 27);
t('5.444517870735015415413993718908291383296e+39', '8', 44);
t('-33338.549041729', '-33338.549041729', 1);
t('2.7214030202002235259872217354276868322505756236796101744750922254072943468398158090938361760503196297567571421573431913968089480080443473498108606049915577803053551131894096917430267992139228904833591260925102332702863889641131058350845466180073805176058062062511496305436593986927276878340795001904960142635221849217162104418149855782368706167456898339731322626805338533602069310753044118499679070391659043014863756212342671519561753648641528938961249781667596503442752009505056776106357574462890625e+355', '25403380.775', 48);
t('-134217728', '-8.00', 9);
t('6.4919612772480684272077477598407081955951769084986853540654908040236664132468736e+31', '4.6', 48);
t('-408518.488', '-74.2', 3);
t('2.6122383559387081296537383480965114437482497294603331038492821930754511334614082451247995976011754175948033208350877260508339210350470971773483611262598975948388081226982520139805939801386768827832059816233575763932242012655210850575522139572300856461682889553829554870249034765972111622144e-53', '0.119534', 57);
t('1.88522188856624562372708154656751441041381726119427387599765763695834615013232142421520586436232009071932931843172032205056661409003338693915273301223126561630347970098203184279906247655542800284362476149094060315694708604230353242909365032002466875120342181047689475694706227284673985251088619705863125778538982501735383260557349198668384156297528069830916927729430864813333996813440323955895348081117644429414429531206777610934118661932545955356203081687958272101e+350', '1396953.01', 57);
t('-7.4641079962956705920034912695642465787383566977879750308559196923222402311665962335871104200586964218306687527948988363660881738310704671349709669487610144905689251123467238632699575375039822099609504292687413249132266915915320573775450823119373280252201183083672896166447786672561808861768782076443312543759437244643146889964363933455672502577964296155349186564340392078021387512970362139779496580009767098175116221996336815276032e+365', '-425417.2', 65);
t('1.915651048048760989675223006710502095760272088541579446290639477213455428121307995153274075329786132157611746651e+72', '363227.051', 13);
t('-7.65032026817518248876564402449082201253180407179105772287243705588834467106246226864795794350056707139677395342984049031608196167e-158', '-0.0000000000008205956327', 13);
t('1.5286700631942576193765185769276826401e+37', '7', 44);
t('1073741824', '8', 10);
t('-7.492788722116264058568890205770570774859100309722464309788118049412229345772411480224300523702767256086276612012745150464681862935165491623598382139203570285583278591609354972796097254467143774807748614976801272704624819215123157317922738427454525033948883547809409740884056108275497786621497433099431568320476275959806764951584862378486525479494452910448127181400467328943711415916384184330110378180608e+38', '-2.6742', 91);
t('-9.9615483925456314514941835282258027490657130453558630944504898425429565393128463181577359582035968e+22', '-34.13672', 15);
t('1.399922200750534682219817715626042346444265577310152832656021878942015248035909712686518235139333930615671437276362060231490721869741275050613538630628001507198150040959125681675660226363983554975062957910826317184614904091530578807538850671607301864207908455029708464592014690257839027200102495492869235566493012545340996194182688131148892605629158333606816661843824439253963260085811270982958376407623291015625e+181', '8668.79595', 46);
t('1.1972515182562019788602740026717047105681e+40', '9', 42);
t('2.809433795080632851709145012225734908409054034941321241601987773815883609706743541544402166343924517939889529050536360240983658675834106822309237371584880050176e+67', '29.26', 46);
t('-1.130764362193076554708917348657069436161383119992010510285626112959278426786936465605907875370782367006311207257151205709430547608789956273155866459033031412425747753017041228269946019068798157376004812291000927158419091251680264057450083682494989856683271885476193403159681085354715517423876371812000883161101039915298940406738346701704184093773206563783365396974283025554248166993067633181013835776e+229', '-495.16', 85);
t('-3.077228040283419501485435148888847716813106712632276671229710377509021026817676725408321326107948661263691709915698886286976007892051135335651197784824163323643144277812710153968406419716183905139635176333083510237302643593683953953477494067043109636077672667948180821005422658784541128359007025402810248257138220199195378601727145592714535208968044372704483391015842523268884989073259915535384596690721656759730286732238685451797332150695395077171985430070293527840123294365665570804795301448909420756992e+418', '-5398620298.48', 43);
t('2591500643510.8703986391408896', '35.620', 8);
t('-3.35390966929685775566428232543003229321430942684482327393890454463616e+26', '-6156.933746', 7);
t('-4911940958770.721866380729238693889243243167048192', '-25.7122', 9);
t('2.09670982511886308779364382461226064522913244291274975553909045464953985730555995547122852179186171376596687978705841751285402054060384366505333092240660435368377833186306191605049e+179', '2093', 54);
t('-1.3120135409024675389197377e-32', '-0.0000000000235855553', 3);
t('3.06580286249339590556181770635869764259023245764469206004664101e-78', '0.0061', 35);
t('-4.429293345196932276984549040219058245905488651609667018402382745119170674779904528756935495114384894434070998056621967747005022674509457845620395626349316891933712941619646377506486625368600115937614507993729672492431012578899815005421568e+37', '-32.051870380', 25);
t('1.299270565684257922619246441017034698039805547412943905460754496572097300952165266370194652051376805296279609746312644347199238836765289306640625e+56', '-18.85', 44);
t('1.566108714385843340192620380546546555641735293434509574033302065853656477829384746549085411912657151882140111651595251043453318950397645765893613409097202898027341727466585518405768283017471302953847629952837298920882176e+24', '41.0192888808596', 15);
t('2.61958676888190130160363553014940478261307337527924200329289138176e+65', '-1866', 20);
t('3.23590932372253866812859949454563891250217856922745576253641197253435665205998361592799809e+89', '2474977', 14);
t('-9.7368504802272205153595678239454304952368475046930119079817985916928e+67', '-12', 63);
t('3.44552147465294110719732986332367243247925798357929806000836849e+62', '-7', 74);
t('128', '2', 7);
t('5.65251025822228531444194278761233641822281792819659230058333528631972497846690920646507426317458140864925211864848848044857090776165664263450974899867329254381660849739991179791628529582217569168185463633540183106805961127540063207424e+251', '-96880334819820', 18);
t('1.214529036103353599078303402353988354368901290518483617131872964733929620706476271152496337890625e+43', '6.5', 53);
t('-1.3089738102615705488950036718911116878301386483323342409513651601949943841095689259436086715966084434967103664037924413474102289403813212913777522181382481044473580351805322191321973e+181', '-78533', 37);
t('1.252453015827223091648143056289e+30', '47', 18);
t('4.593884321465082753417847006029094939767153045428871371185146539475234934788078659649525017869031479813190380591953477672897146298354193774199686172307595609685062957351072442717423824419651156326307969688849329e+172', '34973.7', 38);
t('6.4993779802563991313942147088910855038980304493628711994552936552675080091715543868582664478495863312478503560216160496462563144213423384672637506819444007554298505039521124189159003567749810227911510054190116940785207230365438230686589958633589792785739898681640625e+25', '19.527362557915', 20);
t('22876792454961', '3', 28);
t('429643228077338878294.90980773552148447232', '13385.0992', 5);
t('-7316.89', '-7316.89', 1);
t('5234016485162380478.15409743331356736233224871362317808951664029477472141754368438049197212877764328120319129016485361', '2.41', 49);
t('-9.18448171920669942200338050009727274073573579465100492416464784644248864677562331387086995022599687737054074140424187879986024804042070022603490146718362719056788563440317890910682257768632925460866552260450415793672740716743856864948011399578402033107962721324762764871499139470157293091799845778141752390211181570286270362089589942764421437922022663206638528993662330911966459538905107421403529415706249287725923857606476849002798755812680628308770502507877888997449832630062999974358780733e+247', '-11613.6333', 61);
t('2.648409294963988844015616e-24', '0.0000000138355056', 3);
t('2.40863472207038829716951461596425356200891165327233287498341065017430044564718221477455813374032856667895504085743031089347856425830213625711815509685491800628989456526993157007511653813393067316060298253585492583958097263354394562221211900373157618798878275619835293896301261289133749847496154802330721946407650402052956106639135229248180394944200385403412146150497882700273381421471626181859523581299015700836664867216504968658889499860010034200157321932124862289179191239642591047175122517733014555125735104472403712501002006088016431555682009e+357', '6337.73', 94);
t('-3502571449.82200575261531309080576', '-2.6', 23);
t('1', '1', 25);
t('-1.1809125003067061836785344667120764389443931749265317457525459548456128442105786285468877390219672806038351135283671645849621670658638427296075188535296e+27', '-7.46960', 31);
t('-7804725.584345565904628551916716032', '-1.8', 27);
t('652.68343537143736977925527144667849979675453569710942641839519790994481', '-1.1', 68);
t('1', '-3', 0);
t('4.26825223812027400796974891518773732342988745354489429495479078935112929549619739019072139340757097296812815466676129830954465240517595242384015591919845376e+55', '3.6', 100);
t('1.143346541001259437465016483752642875340200408207372315398374410086504054045958634479945641547514904516533919702060746490155830653988883705469429546657675670673347514271976875109918113055399954802405065425692486675365016543448426931378922954782957026636988416e+190', '-388997.14', 34);
t('1.391479860226959780852496779461260634580951060711489905798047445581119629509685004732118558920853318033429289719854192097911392274604744812177542476869031306237630906988638098552100901480110526866015997536096860367785128698535455722265589251495705036009334110148089566472594008624482378925581538366245059147829461639938451131334656e+162', '785.994', 56);
t('-2.039429275458086101347617297850948854294429450037773018607110681185721614063201210356599410953e+93', '-27753', 21);
t('1.8072708076715752612606017458825273480777271963492548142293548724970849500539908571180569517655791008990836891664536992680448e+43', '64022.984420938', 9);
t('-155568095557812224', '-14', 15);
t('2.18753957001465798602093911444285519704647324430365134831536108015616e+44', '4954.46', 12);
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('2e+0', 2, '1.0');
t('1.6e+1', 2, '4.00000000');
t('6.25e-2', 2, -4);
t('5.0600621890668482322956892808849303e+20', '907.27', 7);
t('-7e+0', '-7', 1);
t('-9.01e+2', '-901', 1);
t('1.016984074247269470395836690098169093010136836967e+39', '21584.7', 9);
t('-8.983272e+1', '-89.83272', 1);
t('5.308416e+6', '-48', 4);
t('3.83432050166120236679168e+23', '52088', 5);
t('-2.679971527468745095582058350756311201706813294321409e+51', '-517889', 9);
t('5.067853299870089529116832768e+2', '3.47508', 5);
t('3.48822062687911109850066182676769e+32', '4129', 9);
t('1e+0', '-429.32321', 0);
t('-4.2773e+0', '-4.2773', 1);
t('-5.8169306081172252508071119604378757744768e+12', '-66.6082', 7);
t('1e+0', '-7.0654', 0);
t('-1.51655708279450944384385164853883404204414169862685507e+46', '-3956084.3', 7);
t('8.1e+1', '-3', 4);
t('1.296e+3', '-6', 4);
t('2.9e+0', '2.9', 1);
t('1.764e+3', '-42', 2);
t('-9.3418332730097368870513138581415704704611459349313e+49', '-356673', 9);
t('1.517108809906561e+15', '79', 8);
t('3.1063e+4', '31063', 1);
t('1e+0', '-21914.49416', 0);
t('1.4586250332983909737249e+10', '49.43', 6);
t('-4.208092749838142546109102616048103440952842087045576022556672e+46', '-4577028.48', 7);
t('3e+0', '3', 1);
t('1.4301918832998497740081358663795354088849575358074712812593899025686055664154241e+71', '784195396.7', 8);
t('1.914994057877243921847839041839022064004621019747303000421532785660701999616e+57', '2315715.86', 9);
t('1.40379741624014849127481344e+26', '804', 9);
t('2.1305364420464979969795870610432e+21', '18437.32', 5);
t('1e+0', '-48', 0);
t('7.018e+3', '7018', 1);
t('-5.8149737003040059690390169e+25', '-729', 9);
t('2.537640625e+9', '50375', 2);
t('1e+0', '-287', 0);
t('-1.879616311308566413901e+11', '-179.81', 5);
t('-3.73314280039567349e+17', '-3269', 5);
t('8.503056e+6', '-54', 4);
t('1.114538684361769559136325232186960408417483078419495901986816e+28', '3205.4344', 8);
t('-4.27504205e+3', '-4275.04205', 1);
t('-4.18195493e+8', '-53', 5);
t('-1.32651e+5', '-51', 3);
t('-4.309348e+6', '-4309348', 1);
t('5.2697770766776504576e+19', '-7259323024', 2);
t('7.334473e+6', '7334473', 1);
t('4.2587208337796928798976e+22', '-674', 8);
t('2.5398714208994744315474847375553672678449979949471296663472852498581058264323e+76', '82219173067', 7);
t('3.8595867893817789e+16', '38595867893817789', 1);
t('1e+0', '6607929.612', 0);
t('2.03571124747179512510686558355453870501244709050625e+34', '-377727882.4895', 4);
t('2.45293306092383728169089251608498030232760591201e+47', '-838901', 8);
t('1e+0', '-3', 0);
t('3.834566459566834602823771544700625e+33', '248845085', 4);
t('9.9603189655699799982630929090395077799549456e+43', '-99900649454', 4);
t('4.96981290961e+11', '-89', 6);
t('1.58714182711801961914035004098749014540213215369889902124332186866896819339082286680313155541911581006508901525889227579394470766224134369e+74', '175595288.8066529', 9);
t('1.326409999413464946341631126231535779147856072448189797080406801e+19', '-60348.91227522707', 4);
t('-2.050107090202653994550415295865311714194868710425929507925126964581376e+69', '-72837546696276', 5);
t('2.0550048143314549586011369057890711537772093948321e+49', '-2129135057417', 4);
t('1e+0', '3943801.89538088', 0);
t('2.17438998607457e+14', '737', 5);
t('-2.273581752472e+10', '-22735817524.72', 1);
t('1.51891070159203e+12', '1518910701592.03', 1);
t('-6.42199562432576e+14', '-86276', 3);
t('1.33010089e+8', '11533', 2);
t('5.1662108991396663099278667856407361e+26', '-4767525.59', 4);
t('-2.197e+3', '-13', 3);
t('5.7261215932713209368576e+22', '489176', 4);
t('2.63105908732834720740862027188940646962896811537209872829318157804817881e+71', '800488505731', 6);
t('-7.8151742291e+2', '-781.51742291', 1);
t('-2.5619022164869008875e+19', '-2947955', 3);
t('1.888497394256858387595532951034741052100428552247961627495355202904723558656e+3', '-6.592180609971056972', 4);
t('1.227102111503512992112190463e+27', '1023', 9);
t('4.762033342402709161761620616017059035607e+39', '86210167', 5);
t('1.0526899962331857933889886363874543386374239042307e+34', '6374705.107', 5);
t('8.3043861038534085480857730707894983974895341475449922046323943309856240866914720437665233e+61','7584431.953', 9);
t('5.4787291089024129877918140548999194405505068584642366052046899220357579072497678119620025119214429570421679076944647727607529032984620150444553526120397e+151', '72419131838243117', 9);
t('6.1203577224967e+13', '61203577224967', 1);
t('-2.6742593337474927167986914400257603e+34', '-82827', 7);
t('3.490938536648870448335810684618787855050175354916141007545163425555957335829e+75', '247548469', 9);
t('6.634204312890625e+15', '-95', 8);
t('-9.171271e+1', '-91.71271', 1);
t('5.65625765123605544067809018296482219675982471958093705254464e+59', '-9093998202', 6);
t('3.518743761e+9', '-39', 6);
t('1e+0', '-5420353171006060062', 0);
t('5.93548365959371477646876280183482286894691258676416e+26', '840398698.65610156', 3);
t('3.05021119744369888239209417566581849921624834657246971302432870103990316674041818082170961e+89', '-820455414011161', 6);
t('3.2696530375744e+11', '571808.8', 2);
t('7.5976962512577721e+4', '-275.639189', 2);
t('1.902906615566371112511312310657143013376e+4', '7.1760176', 5);
t('1.518464318469541965652429354308518011195184133938752135708801e+60', '33317743', 8);
t('2.13200587786233626937431579432326390786198510967574168821917803373975072742648456640669209424089001389646413824e+92', '2444169945946508.968', 6);
t('2.22147484530834915265639755288996e+8', '-14904.612860817114', 2);
t('1.492078384275163354935132877205588401e+36', '-1105217899', 4);
t('-8.7063159741318127407528723363285743789464660953004359884056134456089069164858324456719131936164339926111276712486987242162931090900645752178720048529774274761e+31', '-3538.91793390607241', 9);
t('-2.13718835678657210508559759338095142848187133522908355458407047497607984468725768078407393313580673815584615486794665109272908382172581587476837516398285148210296241056810064518192239263716914808770258390627580625498767684881468120398755080836616073670778327363332334149416019505078840253645081995145611223104498789608205428495349224542916922658293232780298744501314853052243306816366148311919597221018850456061527891844821902500302159789434488225792e+125', '-43837.525307806238', 27);
t('6.6067183217034216835242910438119195789788339709493349261334009277024675568767116522521737472677079426635748603259327817717050761351617610783486587612028204471198915744801916514515768618923473461233676712402753179616115705829361991013069927369820940249862144e+28', '-63581.52864975395137421365938883267810362492', 6);
t('3.4979655423042386318207008930737637967359866053138998526505479068249644854876701482811561341347105355107695596776164641704434681969517211923069874207364828070027467521475982678466251216378786468053405366050900916905682920934733855175647035328921497719019616796867272653837232009633511918699584196136643032274244642212313884180837128156688381283842300678798685499010807063746785776492193558002382725297304258913361e+62', '860658355.93419774133511168973596889241553275604551215135281', 7);
t('2.43e+2', '3', 5);
t('1.1341259418236998571758990926811782086077524757263871423863079766086030645673726799115988350322336274469528121736526520039192242333771040454545272536238688950013853620343757910936524944674880346697808001951639020756685105416346426508389541123017097529060283829118103883424462596062875341251599735321937114348037712815556934333412355272212045907182873831909566029976608100685207198148793211027456e+142', '-77969657.57799062937836', 18);
t('-3.0028686351108853762578194984762919284354267811356443985818417209466959135294437327385632801156377236905276696018118450080884435331856383482308738976558186955588239868161702337334759747439195397392938819582577110829644281561085620841415307488010481547467558616309027516654381610456065415065653113913265920029870297942479155862011879884534002975129045737955826661617772520189976935251896803639204375428428030749e+58', '-3144155.647351179442684823966727126493552586749', 9);
t('1.201753576366394485531985516556867241747342491824062593983537252565487129409802473156809713616241453319630220923725569628522288147931699557284946119375022985149050727430775477724150730989713693887368264655960182781852240604839836052804518341222619522792226084796948765314193322314769946060633722353531243331728258530762514582945950418550784e+31', '27540.61485935537676544614263765574563131573245204', 7);
t('3.37155040678778244943012545203918986928745669295171850695394544390939711301031039954614562269468815944072319615611367890859596537480727045421148118535227427436434942469760108682572253320836320356162649649114580786938367825230347818905248996593031355662611333376e+4', '-3.68110925219710489918033269313682', 8);
t('-1.157385562678413511184308898769846329872668259271078544423253372613586833033423503791374542602879075132311305638124240471079826030985837104460703581522437292662638238646090030670166015625e+186', '-7784665', 27);
t('5.7216584769709576633639728428105243709762039786762015993329350164736e+39', '-8697220540.1137988', 4);
t('3.605080945893673836738483946060969335788919921875e+3', '2.48435', 9);
t('-1.36240450766284865053749603054987406024313651234922549391481734582321604854817272341996695098685037495173906240642212299142117181990034526636150309000822666516664160854969363947955605850108340373472205128364217170231566407701356867606602700453971968987168686696650431666690097496345998516797552915475256643599049488322243247996920458277719083301674288561258518312772229949771006312491204843363917607453589630126953125e+161', '-3009460118.872263767875045', 17);
t('-3.8433712973156659829312033596061261378003902713922379084688365643813353176050190118421109324160544394293788636677094907930777317141076841010276342345029919613746057639577024242309077555840877645790649554834063514938596292845365250946008190566774814236719875110926196028928250892121252859736673222597350006754961294389605594296221696e+157', '-271616.155606', 29);
t('8.880125173267286184293229956929e+30', '-143903', 6);
t('1.2933690030633029978317864458950890700698349292432976269804895466563737201880939364145851524416113479708518067001609042030295271670130750045121e+14', '-7.62048571', 16);
t('4.49118544044091499255717578905704133184433268994940305778505055836352880272044837700029253390614132345790751503571600332872e+26', '765808758.66956931514481639498062905791538', 3);
t('-1.128193052103617375313057818469912250487118062091774976e+29', '-646363.29196', 5);
t('-3.852842458277771128223673975490918109e+4', '-38528.42458277771128223673975490918109', 1);
t('4.47317529320544012507678955001652121720459770030481180787405405093720278140090456738247550862238112656659162732461713512251836889602737214995151906586537236627456e+105', '5932.48', 28);
t('1e+0', '-13.97065588562499', 0);
t('3.600545803275794460618862354918801e+11', '600045.48188248151', 2);
t('2.569380011313067359691205257942517240115628560689496193366261158908199626359277748729466511294505469537479575614097255886064905027804073982599354300474897943e+129', '62080.7', 27);
t('5.818461494039866039726986100228248575472782020261098417686712139322808092966875943575012778303872663798273362332843148103605110550575434794509775866235877112057573531799569068637521409971342270836350080123911710082519119058044202449706075905917444188007277340785315892319100567144025511009943278859996309146349108129588009524947393206783018441414022970002633906397294399684375635228021017590940658971148436650082905540838555648e+102', '6398.880593717242', 27);
t('1.34971356455758975292534311187056647652453780619004003032217331555704261585125261846040712896856946037144900053640398406244356726653396169868958721875222540716653887768486266703330919098362921e+11', '4.1528548909', 18);
t('-1.77396388128500114222945974047586725531284545911409446577e+56', '-913', 19);
t('-1.23493440106890737225414566980096565722401440419412087747352443276574932419181598097379536554237254841727093836607763912665203669933311010821309594074994067411700657618950544400833319706872315553946358432623522564358319794505880365894233180227408889879677018966524371664896e+230', '-90520083747.46', 21);
t('-2.17525001942067723150294558531604730954322658381064353285681098867925681081506083705983156066163186746091443633027643554689317160117967955473175500964155968361524273945120598810972722792061e+14', '-3.121741', 29);
t('1e+0', '-562610.16179592649796590823394093366548', 0);
t('5.5399516545866639955830015026176e+11', '14.94', 10);
t('1.494189395849269188211255039709933309086424259778445906419464942576097148044216376789735318980392750336285644804638743600807550074206128272345650029255016954321611264002141919840462369550905098763723254901675135787504979910497931539962354019230845564318816091666473025536e+126', '-32698949771.110178432792', 12);
t('1.1504940871276742926708823617505372960241390892442547940194260102743306128298973371802547471453755938653944600792141533514422490556963535378521856840746722206160260148176604222079226186281680715577736316488196108040509176925372372483300649927835887344415603493563915019264675154039059770309142781930141352329958156926976e+15', '-8.7358521345995835476', 16);
tx(function () {new Decimal('12.345').pow(void 0)}, ".pow(void 0)");
tx(function () {new Decimal('12.345').pow(null)}, ".pow(null)");
tx(function () {new Decimal('12.345').pow(true)}, ".pow(true)");
tx(function () {new Decimal('12.345').pow(false)}, ".pow(false)");
tx(function () {new Decimal('12.345').pow([])}, ".pow([])");
tx(function () {new Decimal('12.345').pow({})}, ".pow({})");
tx(function () {new Decimal('12.345').pow('')}, ".pow('')");
tx(function () {new Decimal('12.345').pow(' ')}, ".pow(' ')");
tx(function () {new Decimal('12.345').pow('4e')}, ".pow('4e')");
tx(function () {new Decimal('12.345').pow('hello')}, ".pow('hello')");
tx(function () {new Decimal('12.345').pow('\t')}, ".pow('\t')");
tx(function () {new Decimal('12.345').pow(new Date)}, ".pow(new Date)");
tx(function () {new Decimal('12.345').pow(new RegExp)}, ".pow(new RegExp)");
tx(function () {new Decimal('12.345').pow(function (){})}, ".pow(function (){})");
T.stop();
})();
/*
Notes:
n to the power of 1 is n
Anything to the power of 0 is 1
Math.pow(2, null) = 1 // NaN for Decimal
Math.pow(2, undefined) = NaN
Math.pow(2, NaN) = NaN
Math.pow(2, 'rferf') = NaN
Math.pow(2, []) = 1 // NaN for Decimal
Math.pow(2, {}) = NaN // NaN for Decimal
Math.pow(2, 1e4) = Infinity
Math.pow(2, -1e4) = 0
Math.pow(2, 1e-16) = 1
Math.pow(2, -1e-17) = 1
A negative number to a non-integer power is NaN
http://es5.github.com/#x15.8.2.13
15.8.2.13 pow (x, y)
Returns an implementation-dependent approximation to the result of raising x to the power y.
If y is NaN, the result is NaN.
If y is +0, the result is 1, even if x is NaN.
If y is -0, the result is 1, even if x is NaN.
If x is NaN and y is nonzero, the result is NaN.
If abs(x)>1 and y is +Infinity, the result is +Infinity.
If abs(x)>1 and y is -Infinity, the result is +0.
If abs(x)==1 and y is +Infinity, the result is NaN.
If abs(x)==1 and y is -Infinity, the result is NaN.
If abs(x)<1 and y is +Infinity, the result is +0.
If abs(x)<1 and y is -Infinity, the result is +Infinity.
If x is +Infinity and y>0, the result is +Infinity.
If x is +Infinity and y<0, the result is +0.
If x is -Infinity and y>0 and y is an odd integer, the result is -Infinity.
If x is -Infinity and y>0 and y is not an odd integer, the result is +Infinity.
If x is -Infinity and y<0 and y is an odd integer, the result is -0.
If x is -Infinity and y<0 and y is not an odd integer, the result is +0.
If x is +0 and y>0, the result is +0.
If x is +0 and y<0, the result is +Infinity.
If x is -0 and y>0 and y is an odd integer, the result is -0.
If x is -0 and y>0 and y is not an odd integer, the result is +0.
If x is -0 and y<0 and y is an odd integer, the result is -Infinity.
If x is -0 and y<0 and y is not an odd integer, the result is +Infinity.
If x<0 and x is finite and y is finite and y is not an integer, the result is NaN.
*/

263
test/modules/isFiniteEtc.js Normal file
View File

@ -0,0 +1,263 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('isFinite, isInteger, isNaN, isNegative, isZero');
function t(actual) {
T.assert(actual);
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
var n = new Decimal(1);
t(n.isFinite());
t(!n.isNaN());
t(!n.isNegative());
t(!n.isZero());
t(n.isInteger());
t(n.equals(n));
t(n.equals(1));
t(n.equals('1.0'));
t(n.equals('1.00'));
t(n.equals('1.000'));
t(n.equals('1.0000'));
t(n.equals('1.00000'));
t(n.equals('1.000000'));
t(n.equals(new Decimal(1)));
t(n.equals('0x1'));
t(n.equals('0o1'));
t(n.equals('0b1'));
t(n.greaterThan(0.99999));
t(!n.greaterThanOrEqualTo(1.1));
t(n.lessThan(1.001));
t(n.lessThanOrEqualTo(2));
t(n.toString() === n.valueOf());
n = new Decimal('-0.1');
t(n.isFinite());
t(!n.isNaN());
t(n.isNeg());
t(!n.isZero());
t(!n.isInt());
t(!n.equals(0.1));
t(!n.greaterThan(-0.1));
t(n.greaterThanOrEqualTo(-1));
t(n.lessThan(-0.01));
t(!n.lessThanOrEqualTo(-1));
t(n.toString() === n.valueOf());
n = new Decimal(Infinity);
t(!n.isFinite());
t(!n.isNaN());
t(!n.isNegative());
t(!n.isZero());
t(!n.isInteger());
t(n.eq('Infinity'));
t(n.eq(1/0));
t(n.gt('9e999'));
t(n.gte(Infinity));
t(!n.lt(Infinity));
t(n.lte(Infinity));
t(n.toString() === n.valueOf());
n = new Decimal('-Infinity');
t(!n.isFinite());
t(!n.isNaN());
t(n.isNeg());
t(!n.isZero());
t(!n.isInt());
t(!n.equals(Infinity));
t(n.equals(-1/0));
t(!n.greaterThan(-Infinity));
t(n.greaterThanOrEqualTo('-Infinity', 8));
t(n.lessThan(0));
t(n.lessThanOrEqualTo(Infinity));
t(n.toString() === n.valueOf());
n = new Decimal('0.0000000');
t(n.isFinite());
t(!n.isNaN());
t(!n.isNegative());
t(n.isZero());
t(n.isInteger());
t(n.eq(-0));
t(n.gt(-0.000001));
t(!n.gte(0.1));
t(n.lt(0.0001));
t(n.lte(-0));
t(n.toString() === n.valueOf());
n = new Decimal(-0);
t(n.isFinite());
t(!n.isNaN());
t(n.isNeg());
t(n.isZero());
t(n.isInt());
t(n.equals('0.000'));
t(n.greaterThan(-1));
t(!n.greaterThanOrEqualTo(0.1));
t(!n.lessThan(0));
t(!n.lessThan(0, 36));
t(n.lessThan(0.1));
t(n.lessThanOrEqualTo(0));
t(n.valueOf() === '-0' && n.toString() === '0');
n = new Decimal('NaN');
t(!n.isFinite());
t(n.isNaN());
t(!n.isNegative());
t(!n.isZero());
t(!n.isInteger());
t(!n.eq(NaN));
t(!n.eq(Infinity));
t(!n.gt(0));
t(!n.gte(0));
t(!n.lt(1));
t(!n.lte(-0));
t(!n.lte(-1));
t(n.toString() === n.valueOf());
n = new Decimal('-1.234e+2');
t(n.isFinite());
t(!n.isNaN());
t(n.isNeg());
t(!n.isZero());
t(!n.isInt());
t(n.eq(-123.4));
t(n.gt('-0xff'));
t(n.gte('-1.234e+3'));
t(n.lt(-123.39999));
t(n.lte('-123.4e+0'));
t(n.toString() === n.valueOf());
n = new Decimal('5e-200');
t(n.isFinite());
t(!n.isNaN());
t(!n.isNegative());
t(!n.isZero());
t(!n.isInteger());
t(n.equals(5e-200));
t(n.greaterThan(5e-201));
t(!n.greaterThanOrEqualTo(1));
t(n.lessThan(6e-200));
t(n.lessThanOrEqualTo(5.1e-200));
t(n.toString() === n.valueOf());
n = new Decimal('1');
t(n.equals(n));
t(n.equals(n.toString()));
t(n.equals(n.toString()));
t(n.equals(n.valueOf()));
t(n.equals(n.toFixed()));
t(n.equals(1));
t(n.equals('1e+0'));
t(!n.equals(-1));
t(!n.equals(0.1));
t(!new Decimal(NaN).equals(0));
t(!new Decimal(Infinity).equals(0));
t(!new Decimal(0.1).equals(0));
t(!new Decimal(1e9 + 1).equals(1e9));
t(!new Decimal(1e9 - 1).equals(1e9));
t(new Decimal(1e9 + 1).equals(1e9 + 1));
t(new Decimal(1).equals(1));
t(!new Decimal(1).equals(-1));
t(!new Decimal(NaN).equals(NaN));
t(!new Decimal('NaN').equals('NaN'));
t(!new Decimal(NaN).greaterThan(NaN));
t(!new Decimal(NaN).lessThan(NaN));
t(new Decimal('0xa').lessThanOrEqualTo('0xff'));
t(new Decimal('0xb').greaterThanOrEqualTo('0x9'));
t(!new Decimal(10).greaterThan(10));
t(!new Decimal(10).lessThan(10));
t(!new Decimal(NaN).lessThan(NaN));
t(!new Decimal(Infinity).lessThan(-Infinity));
t(!new Decimal(Infinity).lessThan(Infinity));
t(new Decimal(Infinity).lessThanOrEqualTo(Infinity));
t(!new Decimal(NaN).greaterThanOrEqualTo(NaN));
t(new Decimal(Infinity).greaterThanOrEqualTo(Infinity));
t(new Decimal(Infinity).greaterThanOrEqualTo(-Infinity));
t(!new Decimal(NaN).greaterThanOrEqualTo(-Infinity));
t(new Decimal(-Infinity).greaterThanOrEqualTo(-Infinity));
t(!new Decimal(2).greaterThan(10));
t(!new Decimal(10).lessThan(2));
t(new Decimal(255).lessThanOrEqualTo('0xff'));
t(new Decimal('0xa').greaterThanOrEqualTo('0x9'));
t(!new Decimal(0).lessThanOrEqualTo('NaN'));
t(!new Decimal(0).greaterThanOrEqualTo(NaN));
t(!new Decimal(NaN).lessThanOrEqualTo('NaN'));
t(!new Decimal(NaN).greaterThanOrEqualTo(NaN));
t(!new Decimal(0).lessThanOrEqualTo(-Infinity));
t(new Decimal(0).greaterThanOrEqualTo(-Infinity));
t(new Decimal(0).lessThanOrEqualTo('Infinity'));
t(!new Decimal(0).greaterThanOrEqualTo('Infinity'));
t(new Decimal(10).lessThanOrEqualTo(20));
t(!new Decimal(10).greaterThanOrEqualTo(20));
t(!new Decimal(1.23001e-2).lessThan(1.23e-2));
t(new Decimal(1.23e-2).lt(1.23001e-2));
t(!new Decimal(1e-2).lessThan(9.999999e-3));
t(new Decimal(9.999999e-3).lt(1e-2));
t(!new Decimal(1.23001e+2).lessThan(1.23e+2));
t(new Decimal(1.23e+2).lt(1.23001e+2));
t(new Decimal(9.999999e+2).lessThan(1e+3));
t(!new Decimal(1e+3).lt(9.9999999e+2));
t(!new Decimal(1.23001e-2).lessThanOrEqualTo(1.23e-2));
t(new Decimal(1.23e-2).lte(1.23001e-2));
t(!new Decimal(1e-2).lessThanOrEqualTo(9.999999e-3));
t(new Decimal(9.999999e-3).lte(1e-2));
t(!new Decimal(1.23001e+2).lessThanOrEqualTo(1.23e+2));
t(new Decimal(1.23e+2).lte(1.23001e+2));
t(new Decimal(9.999999e+2).lessThanOrEqualTo(1e+3));
t(!new Decimal(1e+3).lte(9.9999999e+2));
t(new Decimal(1.23001e-2).greaterThan(1.23e-2));
t(!new Decimal(1.23e-2).gt(1.23001e-2));
t(new Decimal(1e-2).greaterThan(9.999999e-3));
t(!new Decimal(9.999999e-3).gt(1e-2));
t(new Decimal(1.23001e+2).greaterThan(1.23e+2));
t(!new Decimal(1.23e+2).gt(1.23001e+2));
t(!new Decimal(9.999999e+2).greaterThan(1e+3));
t(new Decimal(1e+3).gt(9.9999999e+2));
t(new Decimal(1.23001e-2).greaterThanOrEqualTo(1.23e-2));
t(!new Decimal(1.23e-2).gte(1.23001e-2));
t(new Decimal(1e-2).greaterThanOrEqualTo(9.999999e-3));
t(!new Decimal(9.999999e-3).gte(1e-2));
t(new Decimal(1.23001e+2).greaterThanOrEqualTo(1.23e+2));
t(!new Decimal(1.23e+2).gte(1.23001e+2));
t(!new Decimal(9.999999e+2).greaterThanOrEqualTo(1e+3));
t(new Decimal(1e+3).gte(9.9999999e+2));
t(!new Decimal('1.0000000000000000000001').isInteger());
t(!new Decimal('0.999999999999999999999').isInteger());
t(new Decimal('4e4').isInteger());
t(new Decimal('-4e4').isInteger());
T.stop();
})();

542
test/modules/ln.js Normal file
View File

@ -0,0 +1,542 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('ln');
function t(n, expected, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).ln().valueOf());
//T.assertEqual(expected, Decimal.ln(n).valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
('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('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.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);
T.stop();
})();

280
test/modules/log.js Normal file
View File

@ -0,0 +1,280 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('log');
function t(n, base, expected, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).log(base).valueOf());
//T.assertEqual(expected, Decimal.log(n, base).valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
/*
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('4', '1024', '0.2', 1, 2);
t('268435456', '1048576', '1.4', 2, 8);
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);
// 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.stop();
})();

523
test/modules/log10.js Normal file
View File

@ -0,0 +1,523 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('log10');
function t(n, expected, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.log10(n).valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: 0,
toExpPos: 0,
minE: -9e15,
maxE: 9e15
});
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);
T.stop();
})();

178
test/modules/log2.js Normal file
View File

@ -0,0 +1,178 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('log2');
function t(n, expected, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.log2(n).valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 'NaN', 40, 4);
t('-1e-234', 'NaN', 40, 4);
t('0', '-Infinity', 40, 4);
t('-0', '-Infinity', 40, 4);
t('1', '0', 40, 4);
t('Infinity', 'Infinity', 40, 4);
// Test powers of 2
for ( var i = 0; i < 54; i++ ) {
t(String(Math.pow(2, i)), String(i), 40, 4);
}
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('7.47572e73', '2.4e+2', 2, 3);
t('2.4e1', '4.5849626e+0', 8, 0);
t('4.443333e5', '1.9e+1', 2, 2);
t('5e-2', '-4.321928094e+0', 10, 2);
t('3.89999999999999996202830641978029954e-2', '-4.68038206e+0', 9, 2);
t('4.087056706550000000000000000000000000459999999999994e-839', '-2.7850666e+3', 8, 5);
t('7.103772438222211905867777771222222222222222288888888806e-81', '-2.66e+2', 3, 6);
t('2e-1', '-2.321928095e+0', 10, 5);
t('7.0327e30', '1.02e+2', 3, 3);
t('7.74113385511898770142564798256591111493439379377358402241596885033503e2', '9.5965e+0', 5, 0);
t('5.0168236102e-7', '-2.092672e+1', 7, 1);
t('3.88888888888888888888888888888888888888888888888888888888888885105520953776999999999999999959888e626', '2.09e+3', 3, 0);
t('3.33333341e-109', '-3.603532e+2', 8, 3);
t('9e7', '2.64234e+1', 6, 5);
t('9.9e-7', '-1.9946e+1', 5, 1);
t('2.9998837933e43', '1.4443e+2', 5, 6);
t('2.280014556961415390190701451555357370581333198813706555078628347239292735244389509334786213e3', '1.1155e+1', 5, 4);
t('9.5e-90', '-2.957e+2', 4, 6);
t('2e893', '2.9674818e+3', 8, 6);
t('8e-27', '-9e+1', 1, 5);
t('1.37e910', '3.0234e+3', 5, 4);
t('8.12836e-7', '-2e+1', 2, 4);
t('1.74e-601', '-2e+3', 2, 3);
t('2e-66', '-2.1824e+2', 5, 2);
t('4.647228466399999999999999999999999999999999999999999999999999999998943563999999999999999999999999999999919327168257748860613941487999999999999999999999e-80', '-2.6353787e+2', 8, 2);
t('6.414199e737', '2.5e+3', 2, 6);
t('9.17e305', '1.01e+3', 3, 1);
t('2.239999999999999999999999933510665347417652e-99', '-3.27707382e+2', 9, 2);
t('1.3897263212335753192678233873729694699999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999e-233', '-7.74e+2', 3, 3);
t('1e29', '9.63e+1', 3, 3);
t('1e-4', '-1.329e+1', 4, 4);
t('3.2e-67', '-2.208912e+2', 7, 3);
t('8e94', '3.1526124e+2', 9, 1);
t('7.106731e51', '1.722475e+2', 7, 4);
t('6.8249734444444444444444444444444444348116222222222222222222222222222222274858072062638524585118791096784e-3', '-7.195e+0', 4, 5);
t('7.9313e-38', '-1.2e+2', 2, 2);
t('9.463228512135835081894413860589e-58', '-1.8943e+2', 6, 3);
t('9.9e-71', '-2.4e+2', 2, 3);
t('3e-96', '-4e+2', 1, 3);
t('6.99448765077869176308972395456786641951135010547854119007664428296218e94', '3.1e+2', 2, 1);
t('6e-473', '-1.568687e+3', 7, 2);
t('8e-36', '-1.165e+2', 4, 1);
t('3.2289084e203', '6.760424e+2', 7, 1);
t('7.22e8', '2.94274236e+1', 9, 0);
t('2.255555555555555830850499999e-684', '-2.2710253e+3', 8, 2);
t('6.1558656863559636e853', '2.836e+3', 4, 3);
t('6.47999624483501572920131e2', '1e+1', 1, 2);
t('8e2', '9.64385619e+0', 10, 4);
t('3.7087506033220685595355297226e77', '3e+2', 1, 5);
t('2.999e-2', '-5.059375e+0', 7, 6);
t('7.622e972', '3e+3', 1, 4);
t('9e897', '2e+3', 1, 1);
t('1.11782576e-27', '-8.9531363e+1', 8, 1);
t('4.2e579', '1.9254668e+3', 8, 6);
t('4.29366e-6', '-1.78293607e+1', 9, 3);
t('2.5e11', '3.786314e+1', 7, 0);
t('2.2e6', '2.10690721e+1', 10, 0);
t('4.4284847498990825381935141920011840774884214901069306287301873764242619177749447748037035404379e-85', '-2.802e+2', 4, 5);
t('1e3', '9.96578e+0', 6, 1);
t('6.6e-7', '-2.0532e+1', 5, 0);
t('8.690141627234254718597780859040018785362077868070223409444967282935124914698055875807134592002580083956972525898044027571687514089085870800669920198834746935239137077743100824925289e7', '2.63728764e+1', 9, 6);
t('8.713956786790365525728798671055089827452503531619162658e-1', '-1.9860013e-1', 8, 1);
t('5.252777777777777777777777777820165941111111162978472887747802033488044444444444444444444444444444e1', '5.71501e+0', 6, 5);
t('9.69573459777908e-362', '-1.1992e+3', 5, 2);
t('7.5569e-740', '-2.45531e+3', 6, 5);
t('9.74035e-490', '-1.6e+3', 2, 1);
t('8e-9', '-2.68973529e+1', 9, 0);
t('1e344', '1.14e+3', 3, 1);
t('3.3e-557', '-1.848591483e+3', 10, 3);
t('2.73e60', '2.0076459e+2', 8, 5);
t('7.6e1', '6.2e+0', 2, 3);
t('7.0060379466068591e-849', '-2.817508354e+3', 10, 3);
t('7e917', '3.049e+3', 5, 5);
t('1.64573410691885658042240459216310152314034696136140858593166940573494665902734186270099e26', '8.708886174e+1', 10, 2);
t('7.796e-44', '-1.4321e+2', 5, 0);
t('5e7', '2.55754247e+1', 9, 1);
t('8.0569e-32', '-1.033e+2', 4, 0);
t('2.28881e-557', '-1.8491e+3', 5, 2);
t('7.09e-724', '-2.4022502e+3', 8, 6);
t('1.59e3', '1.063481105e+1', 10, 4);
t('1.8e-537', '-1.783e+3', 5, 4);
t('5.02569e-2', '-4.3145345e+0', 9, 1);
t('9.999979e-51', '-1.66096e+2', 6, 5);
t('9.95e10', '3.65e+1', 3, 5);
t('3.1e652', '2.168e+3', 4, 5);
t('7e-182', '-6.017835583e+2', 10, 2);
t('5.99999309522985100000000000000000099e5', '1.919460131e+1', 10, 4);
t('9.9e460', '1.53139436e+3', 9, 2);
t('1.1447008929998e5', '1.6805e+1', 5, 4);
t('9.097e-19', '-5.9e+1', 2, 2);
t('6.5e52', '1.75e+2', 3, 1);
t('9.1022e-66', '-2.16061039e+2', 9, 6);
t('5.5e26', '8.9e+1', 2, 2);
t('5.9747169006993667897425525812121903668273701374897278125927633480174019986342932352404691395386370402376825534060778783e-14', '-4.39282e+1', 6, 3);
t('1.94061431409530657832815982480968096203289511358215661231397940293523261488675432814243049614887343783e8', '2.753e+1', 4, 3);
t('9.1129e87', '2.922e+2', 4, 0);
t('8e-6', '-1.6931569e+1', 8, 0);
t('6.958e-344', '-1.14e+3', 3, 6);
t('7.6e5', '1.9535e+1', 5, 3);
t('8.96822222222222222222222222119508e-1', '-1.57106e-1', 6, 4);
t('7.1e7', '2.6e+1', 2, 3);
t('9e-157', '-5.1837e+2', 5, 5);
t('7.3000000000000004188645678064142e249', '8.30028e+2', 8, 0);
t('3e482', '1.602754e+3', 7, 3);
t('4e-393', '-1.30352e+3', 6, 0);
t('8.0683580222567551105228998180452489561929821735260733495394659472e-8', '-2.35e+1', 3, 1);
t('2.5571e4', '1.46422e+1', 6, 5);
t('6e-6', '-1.7e+1', 2, 6);
t('1.863556445038493157629183718741040476555555567232e-19', '-6.221857529e+1', 10, 4);
t('3.4999322222222222222222222222222222e6', '2.1739e+1', 5, 0);
t('8.29442480297413880904354267107722332538975e7', '2.63057e+1', 6, 2);
t('1.6075e519', '1.7247655e+3', 9, 5);
t('5.1e1', '5.67242535e+0', 9, 0);
t('9e64', '2.158e+2', 4, 5);
t('1e-64', '-2.126034e+2', 8, 4);
t('1.2e9', '3.0160387e+1', 8, 6);
t('7.05241041246611819500000000000000000054212400000000000000000000000000000000000042232977062045088556972000000790972e6', '2.27496851e+1', 9, 0);
t('9.99e6', '2.325205325e+1', 10, 2);
t('5.5e8', '2.9034e+1', 5, 1);
t('2.29000000000000000000000000000000941e-6064216', '-2.01448883085178626255335140463713074934932720849229068205713832098265563766344027535592e+7', 87, 0);
t('2.98121814045205686710601835e22573260', '7.4e+7', 2, 3);
t('8.5e-26514', '-8.80745140450022749520253952874708807185261282873713855273316844696e+4', 66, 3);
t('4.27277644444444444445229244718482e59564', '1.9786942021770672585709275516796947196558597384271229335e+5', 56, 5);
t('9.30924698789794524252424189e-7268098', '-2.41440957239301736069970890748362821264083887286824083322114198346358e+7', 69, 2);
t('6.82822995960930271945935479943097116891923770438150513664283749e-73845404', '-2.4530911945439596112646746942354967782562830688718370848616148064936766e+8', 71, 3);
t('5.84609801261197461197367777868584502410357518694058115837e53773873', '1.786329420370789890141941994715176283881591558233e+8', 49, 0);
t('8.688278e-5896', '-1.9582968977189900276130445857722403691239834352860488495115901049392035059e+4', 74, 3);
t('7.49799999999999999e773359', '2.6e+6', 2, 0);
t('6.0058011661556442485511374048366250078225418753938770464520434234268903107102453944e10744', '3.56933818082e+4', 12, 5);
t('8.68630429338007830362222222222222222222222222222222222222224311111492169e-9760', '-3.2418899463607355742502233209726140919e+4', 38, 1);
t('9.52746022222222222222222222222222215664191409361214604694703455030696517727356425411864400894463350397433931235528e804991', '2.67412547112315240639400188262314420772255929501992193312106238120468244451376588594e+6', 84, 1);
t('6.911111111111111111666e1', '6.1108457686882901783628093e+0', 27, 1);
t('8.753466841179514488439739259716095758693108071675972857e23', '7.95342006969539499843372117e+1', 27, 6);
t('6.9293897393471771424368590682187732e-4011970', '-1.33274730661169490860155583127171941591541636281413977719351949586860441308997446e+7', 82, 4);
t('7.248721120952201811052791965700072860844575521374565607742276202674760812016031176300339165917842693831800259732548923e81275591', '2.69991672029200938697950079481902822412413739547133179600205778809e+8', 66, 6);
t('8.839e-750866', '-2.494319717012534627980253814671911210803171821097666700403887940328806381876e+6', 76, 6);
t('2.019694038441111111055555e78', '2.601245281582228388774544331608154321133400916160739209330622912088316832563990039571098875e+2', 91, 0);
t('6.999992707421e-9095', '-3.02101286695814990981946878100430318253824323913669024362543485421644529066733767002654624094e+4', 93, 6);
t('6.573152030373740763721111111111111111111111111111111111111111111111056e-77071', '-2.56021603615710387e+5', 18, 1);
t('7.000003608682e589878', '1.959535108111633331253094708685915889078e+6', 40, 2);
T.stop();
})();

78
test/modules/minAndMax.js Normal file
View File

@ -0,0 +1,78 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('min and max');
function t(min, max, arr) {
T.assertEqual(new Decimal(max).valueOf(), Decimal.max.apply(Decimal, arr).valueOf());
T.assertEqual(new Decimal(min).valueOf(), Decimal.min.apply(Decimal, arr).valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
t(NaN, NaN, [NaN]);
t(NaN, NaN, [-2, 0, -1, NaN]);
t(NaN, NaN, [-2, NaN, 0, -1]);
t(NaN, NaN, [NaN, -2, 0, -1]);
t(NaN, NaN, [NaN, -2, 0, -1]);
t(NaN, NaN, [-2, 0, -1, new Decimal(NaN)]);
t(NaN, NaN, [-2, 0, -1, new Decimal(NaN)]);
t(NaN, NaN, [Infinity, -2, 'NaN', 0, -1, -Infinity]);
t(NaN, NaN, ['NaN', Infinity, -2, 0, -1, -Infinity]);
t(NaN, NaN, [Infinity, -2, NaN, 0, -1, -Infinity]);
t(0, 0, [0, 0, 0]);
t(-2, Infinity, [-2, 0, -1, Infinity]);
t(-Infinity, 0, [-2, 0, -1, -Infinity]);
t(-Infinity, Infinity, [-Infinity, -2, 0, -1, Infinity]);
t(-Infinity, Infinity, [Infinity, -2, 0, -1, -Infinity]);
t(-Infinity, Infinity, [-Infinity, -2, 0, new Decimal(Infinity)]);
t(-2, 0, [-2, 0, -1]);
t(-2, 0, [-2, -1, 0]);
t(-2, 0, [0, -2, -1]);
t(-2, 0, [0, -1, -2]);
t(-2, 0, [-1, -2, 0]);
t(-2, 0, [-1, 0, -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(-1, 1, ['-1', 0, new Decimal(1)]);
t(-1, 1, ['-1', new Decimal(1)]);
t(-1, 1, [0, '-1', new Decimal(1)]);
t(0, 1, [0, new Decimal(1)]);
t(1, 1, [new Decimal(1)]);
t(-1, -1, [new Decimal(-1)]);
t(0.0009999, 0.0010001, [0.001, 0.0009999, 0.0010001]);
t(-0.0010001, -0.0009999, [-0.001, -0.0009999, -0.0010001]);
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]);
t(-3, 3, [1, '2', 3, '-1', -2, '-3']);
T.stop();
})();

1050
test/modules/minus.js Normal file

File diff suppressed because it is too large Load Diff

1079
test/modules/mod.js Normal file

File diff suppressed because it is too large Load Diff

226
test/modules/neg.js Normal file
View File

@ -0,0 +1,226 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('negated');
function t(expected, n) {
T.assertEqual(expected, new Decimal(n).neg().valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
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('0', -0);
t('-0', '0');
t('0', '-0');
t('NaN', NaN);
t('NaN', 'NaN');
t('-Infinity', Infinity);
t('Infinity', -Infinity);
t('-Infinity', 'Infinity');
t('Infinity', '-Infinity');
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('0', '-1e-9000000000000001');
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('-5', '5.0');
t('-2463.4', '2463.4');
t('7.363', '-7.363');
t('2.8', '-2.8');
t('-14498', '14498');
t('201', '-201');
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.stop();
})();

1046
test/modules/plus.js Normal file

File diff suppressed because it is too large Load Diff

133
test/modules/pow.js Normal file
View File

@ -0,0 +1,133 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('pow');
t = function (base, exp, expected, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.pow(base, exp).valueOf());
T.assertEqual(expected, new Decimal(base).pow(exp).valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
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('4', '6.5', '8192', 10, 4);
t('6.034', '0.25964', '2', 1, 4);
t('9', '4.5', '19683', 16, 4);
t('9', '1.5', '27', 5, 4);
t('9.61', '3.5', '2751.2614111', 12, 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('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('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('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('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('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('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('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('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;
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('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);
T.stop();
})();

42
test/modules/powSqrt.js Normal file
View File

@ -0,0 +1,42 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('pow against sqrt');
Decimal.config({
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
for (var e, n, p, r, s; total < 10000; ) {
// Get a random value in the range [0,1) with a random number of significant digits
// in the range [1, 40], as a string in exponential format.
e = Decimal.random( Math.random() * 40 + 1 | 0 ).toExponential();
// Change exponent to a non-zero value of random length in the range (-9e15, 9e15).
r = new Decimal(e.slice(0, e.indexOf('e') + 1) + ( Math.random() < 0.5 ? '-' : '' ) +
( n = Math.floor( Math.random() * 9e15 ) + '' ).slice( Math.random() * n.length | 0 ));
//T.write(' r: ' + r);
// Random rounding mode.
Decimal.rounding = Math.random() * 9 | 0;
// Random precision in the range [1, 40].
Decimal.precision = Math.random() * 40 + 1 | 0;
p = r.pow(0.5);
//T.write(' r.pow(0.5): ' + p);
// sqrt is much faster than pow(0.5)
s = r.sqrt();
//T.write(' r.sqrt(): ' + s);
T.assertEqual(p.valueOf(), s.valueOf());
}
T.stop();
})();

32
test/modules/random.js Normal file
View File

@ -0,0 +1,32 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('random');
function tx(fn, msg) {
T.assertException(fn, msg);
}
var i, sd, maxDigits = 100;
for (i = 0; i < 996; i++) {
Decimal.crypto = Math.random() > 0.5;
sd = Math.random() * maxDigits + 1 | 0;
if (Math.random() > 0.5) {
Decimal.precision = sd;
r = Decimal.random();
} else {
r = Decimal.random(sd);
}
T.assert(r.sd() <= sd && r.gte(0) && r.lt(1) && r.eq(r) && r.eq(r.valueOf()));
}
tx(function () { Decimal.random(Infinity) }, 'Infinity');
tx(function () { Decimal.random('-Infinity') }, "'-Infinity'");
tx(function () { Decimal.random(NaN) }, 'NaN');
tx(function () { Decimal.random(null) }, 'null');
T.stop();
})();

527
test/modules/round.js Normal file
View File

@ -0,0 +1,527 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('round');
function t(expected, n, rm) {
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).round().valueOf());
T.assertEqual(expected, Decimal.round(n).valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
t('Infinity', 'Infinity', 4);
t('-Infinity', '-Infinity', 4);
t('NaN', 'NaN', 4);
t('0', '0', 4);
t('-0', '-0', 4);
t('1', '1', 4);
t('-1', '-1', 4);
t('0', '0.1', 4);
t('-0', '-0.1', 4);
t('0', '1e-9000000000000000', 4);
t('-0', '-1e-9000000000000000', 4);
t('9.999e+9000000000000000', '9.999e+9000000000000000', 4);
t('-9.999e+9000000000000000', '-9.999e+9000000000000000', 4);
t('6.88054606464877886407425549768282761571350053022023236e+53', '6.880546064648778864074255497682827615713500530220232351811172615965890936e+53', 0);
t('9.51833733815343753238388e+23', '9.51833733815343753238387581003146664685764843969081033323613e+23', 5);
t('4.434086046379498022164479619323e+30', '4.4340860463794980221644796193222113345e+30', 0);
t('913844451463', '913844451463.2968716291911429329', 4);
t('4.124227112152123941928547272459545727985864897598835e+51', '4.1242271121521239419285472724595457279858648975988352729535839522490471492602734474826e+51', 3);
t('4.63429955102358262449651440722058050134341793502231565647729228272e+65', '4.634299551023582624496514407220580501343417935022315656477292282722482758912005500689831e+65', 3);
t('28923471241', '28923471241.98034587766743552', 1);
t('4521981137129745', '4521981137129744.67989385131579785422314397', 0);
t('1.757029854153590067583921300868154608080526623790036985862257948987889309489e+76', '1.7570298541535900675839213008681546080805266237900369858622579489878893094889309687763293350816e+76', 2);
t('7.92779841419157112811950427049997777808175311282606971649180221573863785195e+74', '7.92779841419157112811950427049997777808175311282606971649180221573863785194619091321130332110043278383964781191e+74', 6);
t('4.8046702619549660118837319476958242e+34', '4.80467026195496601188373194769582420063536104857816444372396235915e+34', 6);
t('16604074202686788', '16604074202686787.6', 0);
t('2.03054429543856309099719183163085279314546339909457784263114937593e+67', '2.0305442954385630909971918316308527931454633990945778426311493759300288903340472095271466713787146011e+67', 1);
t('30559986845', '30559986844.828104310332245126047', 5);
t('3.169159034649715925059423431889057069973085990306134577512910339e+63', '3.16915903464971592505942343188905706997308599030613457751291033998309334924157348709083e+63', 1);
t('2.74536925513947196644678859506681278043361770523611795129e+56', '2.74536925513947196644678859506681278043361770523611795129033731273249555974944131605156319693351e+56', 1);
t('3.836711661609490207325966566e+27', '3.83671166160949020732596656539593198724761580767321062612029068e+27', 2);
t('9.5917250469401862241299735910188523300291350099849e+49', '9.591725046940186224129973591018852330029135009984930929359628823555090675843e+49', 3);
t('21333682', '21333681.9', 0);
t('8.62022856983460008434772295e+26', '8.62022856983460008434772295e+26', 3);
t('68042277', '68042276.936331', 4);
t('4.8750036651483452171308023e+25', '4.875003665148345217130802304e+25', 5);
t('1.3591935058296677548790388717577585193715249e+43', '1.35919350582966775487903887175775851937152497849507394160868e+43', 1);
t('4129', '4128.8573915082798234283182739502433923', 2);
t('6.25825257883805843076111330243671881564726599e+44', '6.2582525788380584307611133024367188156472659814623144865497e+44', 0);
t('2.073939185723766359554288e+24', '2.0739391857237663595542878001922882482361918639e+24', 6);
t('5.145015399473362034445178801296467411193767021458e+48', '5.1450153994733620344451788012964674111937670214584134294502818008587093553744e+48', 4);
t('3.7741249292961331651914274171432415480188820147e+46', '3.7741249292961331651914274171432415480188820147914167e+46', 3);
t('2.5907197709663090692786288643e+28', '2.59071977096630906927862886428517500364162734e+28', 4);
t('6.5019848918413133548151232394242295281947013425358575908400718513465e+67', '6.5019848918413133548151232394242295281947013425358575908400718513464661016174107270809281124152327737993e+67', 4);
t('6.5654656243131424283006345840695185206252e+40', '6.56546562431314242830063458406951852062516491733e+40', 4);
t('7.14296188550926336386536585191594379995651640918449914847192e+59', '7.1429618855092633638653658519159437999565164091844991484719191390713140556399248288684716160792764e+59', 0);
t('1.65831307344278205652667503e+26', '1.6583130734427820565266750303412035297508422789795074468453e+26', 3);
t('1.03868076642005814047021881e+26', '1.038680766420058140470218801950252025537802241e+26', 2);
t('346', '346.452605374950482582868219', 4);
t('181439315463425985534', '181439315463425985534.25865844894077275430318757', 3);
t('8113502102248864193', '8113502102248864193.4', 6);
t('2.0396642160540139112491673463348213536632845904136202928864236188830882179e+73', '2.0396642160540139112491673463348213536632845904136202928864236188830882178287498700128363702734e+73', 0);
t('57217688166662318', '57217688166662318.14978073061366795927750180227408203205', 1);
t('1.3263967367823644477766479033175434612e+37', '1.32639673678236444777664790331754346122524765959079128749150122574912710232e+37', 6);
t('4.097858435839183181158056560760949599139954068194535406240460058272877614656e+75', '4.0978584358391831811580565607609495991399540681945354062404600582728776146564387e+75', 1);
t('9.53862376611854437580813e+23', '9.5386237661185443758081265964082575366510636210576058e+23', 2);
t('9.49667001930609829678887507025575441813606832788e+47', '9.49667001930609829678887507025575441813606832787403591376232279326592e+47', 0);
t('6.10292467565130496104458878537476362133917639257694305498260179044673420925478e+77', '6.102924675651304961044588785374763621339176392576943054982601790446734209254780222e+77', 6);
t('1.3569526432875110743338e+22', '1.3569526432875110743338802291960156552161e+22', 1);
t('37621189552', '37621189552.4548804003545304449', 4);
t('3.7760257582328104673720218606494623716708788e+43', '3.776025758232810467372021860649462371670878868908226307307668506118232e+43', 1);
t('7.74525800334839542704379514512194550565400271258796650103830226e+62', '7.745258003348395427043795145121945505654002712587966501038302267977111236789268316426418098716e+62', 1);
t('6.2644488671934926960298323609173878562204e+40', '6.264448867193492696029832360917387856220314258629579154805116236617047705e+40', 2);
t('1.1212610202715126696808411919523222015979206841671840577694468e+61', '1.12126102027151266968084119195232220159792068416718405776944683512488141027069261455294944060583439e+61', 4);
t('14768', '14768.1842134501472446153274412575133', 1);
t('66', '65.84595269', 4);
t('5.04358552116975225426776135857493312e+36', '5.0435855211697522542677613585749331194437753499183689199959863339211e+36', 2);
t('72916866821', '72916866820.54423629685259893346337712794', 5);
t('2.25398641434088868230960319957704440329914057033993092762174e+59', '2.253986414340888682309603199577044403299140570339930927621742643835298453365292983113173554605e+59', 6);
t('9.50878709595470892500629632386714322909202072012758393749698817348e+65', '9.508787095954708925006296323867143229092020720127583937496988173481432728097661248708213e+65', 5);
t('5.2607910472629613651015532597249206745434137969950236424916019135420122e+70', '5.260791047262961365101553259724920674543413796995023642491601913542012227611433312032956077032041978908e+70', 1);
t('410', '410.762791093715303350001444121070121', 1);
t('1.3320871624020377318642711553436113e+34', '1.33208716240203773186427115534361135519309237757872381699115467e+34', 1);
t('6230378575909', '6230378575908.126534764593955', 2);
t('8.79324953269900537785265055241483017965551931338157086204822343837345e+68', '8.793249532699005377852650552414830179655519313381570862048223438373446168669586851714244432e+68', 0);
t('7.808570916258060849165e+21', '7.8085709162580608491646e+21', 5);
t('88', '87.426', 2);
t('5036', '5035.551403129954', 2);
t('4.666777096688297335109779706846177431928559905049197884212958955e+63', '4.6667770966882973351097797068461774319285599050491978842129589550252836742465454224095908e+63', 6);
t('1.3082493338072034134280214605195699691716814374132145e+52', '1.30824933380720341342802146051956996917168143741321444089754461241e+52', 0);
t('82896368014641073413', '82896368014641073413.127', 3);
t('3.6759908238598981366541946858543288181344210687261e+49', '3.6759908238598981366541946858543288181344210687260953004e+49', 2);
t('2554853', '2554853.448817348736141', 5);
t('7.432653329376812932864567362402827202784593426455497e+51', '7.43265332937681293286456736240282720278459342645549756393442032908961e+51', 1);
t('4.1376083180004347798256857059806342e+34', '4.13760831800043477982568570598063412322243503351025693e+34', 0);
t('2.81639743586035847441737607898e+29', '2.816397435860358474417376078971272140333871184e+29', 2);
t('3.33308755377081894459518719001618476646619e+41', '3.33308755377081894459518719001618476646619345374865441860199004e+41', 4);
t('861198584370', '861198584370.487', 1);
t('58138545', '58138545.527841812778081669334', 3);
t('9.1299443667780696881942861253757909197956397717814491253e+55', '9.12994436677806968819428612537579091979563977178144912531e+55', 1);
t('4.39311758031073540977322723016501396453173282821704760525204945353983876096252e+77', '4.39311758031073540977322723016501396453173282821704760525204945353983876096251821769058876287518283551757703348408464e+77', 2);
t('3.2974115909070248542274425313413005934211172865969028889e+55', '3.297411590907024854227442531341300593421117286596902888853804228063794921468e+55', 2);
t('54', '53.34398845927930853307662313597656146', 0);
t('15636384601748303', '15636384601748302.9811', 2);
t('2.3043720261427013162485e+22', '2.3043720261427013162485531143187502464942974003324599e+22', 1);
t('581057837085', '581057837085.65123531004522490062077436676334724089', 3);
t('797366496337', '797366496337.6718190234426526346293683404803880987062', 1);
t('4.285881357494659223685e+21', '4.285881357494659223685e+21', 6);
t('9.132045135982774098345e+21', '9.13204513598277409834525940084399290647033372055570535606505e+21', 4);
t('1.11669335324060757880756755605946384713132737403413e+50', '1.1166933532406075788075675560594638471313273740341292905922955935106577859270853666e+50', 5);
t('3.23832893865411943993037855346860219715891545114e+47', '3.238328938654119439930378553468602197158915451147002264725e+47', 3);
t('7.40310708864509274393878672061390994720684311147946750446044572e+62', '7.4031070886450927439387867206139099472068431114794675044604457234765307070001457084110726e+62', 1);
t('3.68965336119015432161651754041004e+32', '3.68965336119015432161651754041003908937708794285e+32', 2);
t('90783322754206050', '90783322754206049.35035', 2);
t('4.783897483734883940914066109558172639368953766427218188058842e+60', '4.783897483734883940914066109558172639368953766427218188058842519826992028703726005242207628819478632e+60', 3);
t('8.74642362004856279856821278562300234968553e+41', '8.7464236200485627985682127856230023496855266153880604628901734609882681e+41', 4);
t('2.787528073145134085377480268092975211744788266156563860706325e+60', '2.787528073145134085377480268092975211744788266156563860706324907236200247422339482e+60', 0);
t('9.044749264159923044896e+21', '9.0447492641599230448952113830135543025323624505592e+21', 0);
t('3.38724858450634217020878619249322e+32', '3.3872485845063421702087861924932165998628685152854e+32', 5);
t('7.33035174941232251216660134923e+32', '7.33035174941232251216660134923000387370975884e+32', 3);
t('3.31861301560113994278653457913815811504895843883387949739855080482136508e+71', '3.318613015601139942786534579138158115048958438833879497398550804821365076078023599771341067964e+71', 2);
t('4.892538135085055040561465460077728050505789433e+45', '4.892538135085055040561465460077728050505789433039013e+45', 3);
t('3.480927423683982545690946611905582393906288848845e+48', '3.4809274236839825456909466119055823939062888488451700237682978275240792e+48', 6);
t('8.5585370645750825066579e+22', '8.5585370645750825066579059239556661179388558223611585366682692e+22', 5);
t('2.8106502332881758642573040950398356187983397721051055759182e+58', '2.810650233288175864257304095039835618798339772105105575918210150772785811e+58', 4);
t('7.953951085584591494904819e+25', '7.9539510855845914949048190132594822824626976317642169018875166767e+25', 5);
t('5012920663454824', '5012920663454823.94', 4);
t('9.059308645970286362603799e+24', '9.059308645970286362603799e+24', 4);
t('2.930381009176059877391197659254717127145084478e+45', '2.93038100917605987739119765925471712714508447815186763294045321221268221587573e+45', 1);
t('3.93979729202599788234456028398138395381138418403803935560263301961568e+68', '3.939797292025997882344560283981383953811384184038039355602633019615681383938905911925353290603787e+68', 5);
t('3.347294783804407389536880406224847102831717725051604392715997e+60', '3.3472947838044073895368804062248471028317177250516043927159970180531e+60', 1);
t('4.152557275792933219421015403627280983623385245443758047431e+57', '4.1525572757929332194210154036272809836233852454437580474305470338495945e+57', 4);
t('2.568943282775480373543498502026413633372529080072386778478497168e+63', '2.56894328277548037354349850202641363337252908007238677847849716763891609585410420915975309606355e+63', 2);
t('8.684093992464956330645701447343516418e+36', '8.684093992464956330645701447343516417923741184554719792596139808816571956653e+36', 5);
t('5.83803824336815109774392e+23', '5.838038243368151097743916928821585630595573416851e+23', 0);
t('4.99449017842808893066894421324882543343399403548140337811028587e+62', '4.994490178428088930668944213248825433433994035481403378110285871375e+62', 1);
t('4.3792711449156782662938969897476619220638522535235560693017440318235650762880312e+79', '4.379271144915678266293896989747661922063852253523556069301744031823565076288031203e+79', 6);
t('1.64836570856055370302116821082684227150215611327936660631e+57', '1.6483657085605537030211682108268422715021561132793666063097975046239608762642599531985480246e+57', 4);
t('3.6880029140410668344606480164489384e+34', '3.68800291404106683446064801644893833152881384958720719932324749064e+34', 2);
t('5.37691884604259144480804415625800887790938772497524135e+53', '5.376918846042591444808044156258008877909387724975241352981212067476945435681674020225105e+53', 3);
t('7.1995513358058164351942e+22', '7.199551335805816435194169107730917957459e+22', 5);
t('55248039093404', '55248039093404.6273291498305797535238516736182191', 3);
t('6.419830543451423871631416632166320919709e+39', '6.41983054345142387163141663216632091970977470919817409169e+39', 3);
t('47', '46.679687957019966', 5);
t('8.846171889181456596809377139e+27', '8.8461718891814565968093771394637497527855234030610736533458882022e+27', 5);
t('9494812039339485', '9494812039339484.66504814190507971', 2);
t('9.568743436371491059070139104936123822e+36', '9.568743436371491059070139104936123822153171585452165317540885e+36', 4);
t('6.218950733005184405477309653091850341440038341422433362937950160976e+66', '6.218950733005184405477309653091850341440038341422433362937950160975956092596313331825e+66', 2);
t('8.3184242277151497735548563861150757508026e+40', '8.318424227715149773554856386115075750802554724068866714143812e+40', 5);
t('44238479', '44238479.45577788940469598821356176', 5);
t('2037', '2037.823568704255455386618400409335477', 3);
t('5.436649951976429287545774447705520810310093287073075e+51', '5.436649951976429287545774447705520810310093287073074686050425310198538528694387158388e+51', 6);
t('37738994177', '37738994177', 5);
t('9.117326071348610688176527980615463581736346164592577593e+54', '9.11732607134861068817652798061546358173634616459257759341133852768832521419919626360171e+54', 5);
t('6.084920955300075178735187946364763863e+36', '6.08492095530007517873518794636476386223409771383197420966e+36', 2);
t('8.522483763341817511064e+21', '8.5224837633418175110636e+21', 2);
t('8089235072415301', '8089235072415301.5407182501479888352094914490764', 3);
t('6588524', '6588524.3302879765427617637496749722', 4);
t('6.48949404289677464226944079045203282327984360168518221116940520131007087e+71', '6.48949404289677464226944079045203282327984360168518221116940520131007086776011881e+71', 5);
t('4.66758032658209403400328094282546162268665050304684900737759e+59', '4.6675803265820940340032809428254616226866505030468490073775840892679e+59', 0);
t('3.8228501778813845182718352582392492990500025013409025197209162241766597698593466e+79', '3.82285017788138451827183525823924929905000250134090251972091622417665976985934664e+79', 3);
t('1.48107423197776804105574657092158563e+36', '1.48107423197776804105574657092158563064846301871291470178376174e+36', 3);
t('687436488212973', '687436488212972.3776181461101284022701451638', 0);
t('1.3723738401752233053350007148932102e+34', '1.37237384017522330533500071489321018e+34', 4);
t('7.62478294482680439921089600929940725974552200617448002491e+56', '7.6247829448268043992108960092994072597455220061744800249106939240528761312396549902e+56', 4);
t('85960397435', '85960397434.6658395', 4);
t('2.763384545224304050146832313739655508577774027132280259541365597279123017482e+75', '2.763384545224304050146832313739655508577774027132280259541365597279123017482371912033266310613516271663e+75', 5);
t('3807642124967812864', '3807642124967812863.11134193333490873646020100055', 2);
t('6.70427065774694862425851113103666872565875637413102437053e+57', '6.704270657746948624258511131036668725658756374131024370529849179417160857194136e+57', 2);
t('5.847413670589089981708716357368937643792827522e+45', '5.8474136705890899817087163573689376437928275218768e+45', 0);
t('8.05036521767882485190836e+23', '8.0503652176788248519083693278838868065648e+23', 1);
t('2.388213850732309089626300468433832206510001e+42', '2.38821385073230908962630046843383220651000054e+42', 5);
t('8.650286818819557970446473110946463648974025293138e+48', '8.65028681881955797044647311094646364897402529313791495118107976573745115e+48', 4);
t('1.06125356153442428148614416928268031052670523838e+47', '1.06125356153442428148614416928268031052670523837841483302500724891691386968e+47', 5);
t('6.051458835569184364025914e+24', '6.0514588355691843640259134539571989823409365353609022460399600829e+24', 2);
t('5255333', '5255332.88023478522156979504635801765441542', 5);
t('6.6440556280518454677778e+23', '6.64405562805184546777779589612592222e+23', 4);
t('933398330878877265', '933398330878877264.71837776272423433960446407792842', 5);
t('1.646563999089466617840308582e+27', '1.6465639990894666178403085828775007164048968602872689633441291356e+27', 3);
t('2.04071424062649763402922072340235937591717327451273251540381e+59', '2.04071424062649763402922072340235937591717327451273251540381641481881855e+59', 1);
t('6.207910504118590442964e+21', '6.20791050411859044296423935427955051266259547322838791883672e+21', 5);
t('8.43012542075846388096939598702013e+32', '8.43012542075846388096939598702013178561e+32', 6);
t('32973411322', '32973411322.0055', 1);
t('7.41694510786524937341518027227253887932818592426915463600522309825048431e+71', '7.416945107865249373415180272272538879328185924269154636005223098250484307079446594739006612417e+71', 2);
t('6', '5.9619856716250354871335057', 2);
t('87527', '87526.63684823518483851567239869752', 4);
t('9.763022525200483641130669988156219e+34', '9.763022525200483641130669988156219073728900962111054931e+34', 3);
t('8.6185312763805220809689217680237306487385577826341538e+52', '8.61853127638052208096892176802373064873855778263415380693587684e+52', 6);
t('8.45360239012103000688834251686727e+33', '8.45360239012103000688834251686726987255777523693637285554668319e+33', 0);
t('2518723195860416961', '2518723195860416961.1285010663484912294197393809044612', 1);
t('2.685500253120233156790885090189119970660485355223415640469844965503956949e+72', '2.6855002531202331567908850901891199706604853552234156404698449655039569485280575699687713e+72', 2);
t('220453411', '220453411.8828467378639975405350886112158605', 1);
t('4.85547756175076698605434224480862417426276770270709846574910398927491662348382e+77', '4.85547756175076698605434224480862417426276770270709846574910398927491662348381810254102042363e+77', 2);
t('706', '705.772547316850746', 6);
t('7.922244228553676441225996043345713795845944777e+45', '7.92224422855367644122599604334571379584594477725845245459550132153e+45', 1);
t('5.2423675401973461629044e+22', '5.242367540197346162904370934159243342332619e+22', 5);
t('18030585831906130', '18030585831906130.962417491553869302', 1);
t('9.1579489825538072699342096635557184539890411086285024230055732e+61', '9.1579489825538072699342096635557184539890411086285024230055732145647118262972725923e+61', 1);
t('85226070565187', '85226070565186.749650937595330322325285761974396', 0);
t('5.8026252767502790532863416020671786591156722564880455114e+55', '5.80262527675027905328634160206717865911567225648804551136391722488e+55', 5);
t('2.4218610164284422911400259009366691043836e+40', '2.4218610164284422911400259009366691043835892289395393055927142431986156068766091e+40', 2);
t('9.06687520914843144090853802874797707391234306e+44', '9.066875209148431440908538028747977073912343061e+44', 4);
t('9.277380564234452159463923699924423033503589164006560028593034039059e+66', '9.2773805642344521594639236999244230335035891640065600285930340390595049193598441e+66', 3);
t('8.128082895667773893079564235647181e+33', '8.128082895667773893079564235647180709738816611273e+33', 0);
t('36', '36.956949377301', 1);
t('1.87389296164121983463708427608894171918413437553511848334553945494023535764718e+77', '1.873892961641219834637084276088941719184134375535118483345539454940235357647177900767e+77', 6);
t('17310978329', '17310978328.5287351707255015885210716726522112', 6);
t('9.2600219512947966032033927978963555790720436638836388e+52', '9.260021951294796603203392797896355579072043663883638828801926062258412645086313910012864e+52', 4);
t('14575632844', '14575632843.9255237386639144', 4);
t('6.6321582910691070759469809878367695902421451930245389e+52', '6.6321582910691070759469809878367695902421451930245388163039e+52', 0);
t('7.25572991620854492306001e+23', '7.25572991620854492306000246e+23', 2);
t('2.29944904912666115204337635383054709834656882596225337344e+56', '2.299449049126661152043376353830547098346568825962253373445377477443437271765291716e+56', 1);
t('5.20558341173907182519017950869849925033417917e+44', '5.205583411739071825190179508698499250334179162775097e+44', 0);
t('6111649076', '6111649076.222604966937070801102488363059341', 6);
t('9.11024271273341770350822200927358669721049157581569029e+53', '9.11024271273341770350822200927358669721049157581569028990662687474e+53', 0);
t('4.43687659677981757715075653509475056586153598815659143662113577e+62', '4.43687659677981757715075653509475056586153598815659143662113577090918204e+62', 3);
t('248', '247.654291674654270796798279', 4);
t('4.3600875972057143805604498896639034411838346245016392883967078243062789210025219e+79', '4.3600875972057143805604498896639034411838346245016392883967078243062789210025219430426344800669971036134643124803e+79', 3);
t('1.03007021065884639208787111225352947659134e+41', '1.03007021065884639208787111225352947659134e+41', 5);
t('6.6928769403416121328026875807e+28', '6.69287694034161213280268758078544463630255731257270872775864425e+28', 3);
t('32434285307875262', '32434285307875262.2207922459899301806', 6);
t('62748749332151342301', '62748749332151342301.19244', 5);
t('4.0678262988827413231899e+22', '4.06782629888274132318985446914450533e+22', 2);
t('9082662703546', '9082662703546.324370805591057', 6);
t('8.94871836341303529473698033715697e+32', '8.9487183634130352947369803371569600373840782e+32', 0);
t('2.1670379409405843366171258653978628564316145348035311924089e+58', '2.1670379409405843366171258653978628564316145348035311924089239541816857773897563368575797031936041e+58', 6);
t('2935893', '2935892.87182124', 2);
t('4.37578044122813627924254711867936993527178454e+44', '4.375780441228136279242547118679369935271784531302743e+44', 0);
t('6.39286534756971472039e+21', '6.39286534756971472038980039416071834909341307858e+21', 6);
t('4.18258479181585354438902084125374066e+35', '4.182584791815853544389020841253740662e+35', 3);
t('2.9635549088358495388694647078277775625649e+40', '2.96355490883584953886946470782777756256487239375833003125e+40', 0);
t('9.199438690858434123332123544047e+30', '9.19943869085843412333212354404671487370041239840183084655999684e+30', 4);
t('3.29539383367054908280466428e+26', '3.2953938336705490828046642886489630335793970083516425663e+26', 1);
t('5.4864050382187254727117788923745e+31', '5.48640503821872547271177889237442590120046642432614e+31', 2);
t('6.72291657980520450527702159742964874909944380115207127826868e+59', '6.7229165798052045052770215974296487490994438011520712782686756677317729908042785747274547904999e+59', 5);
t('6.4199675010715062595232405405532880703928738044906019996020105471838488933611956e+79', '6.41996750107150625952324054055328807039287380449060199960201054718384889336119552687e+79', 0);
t('8.49573393504083151850167234209249202511578741027519908816390028552e+65', '8.495733935040831518501672342092492025115787410275199088163900285521533395797589e+65', 5);
t('1.5955208479300521845981764334575800052437447146562787571491109848403080783e+73', '1.59552084793005218459817643345758000524374471465627875714911098484030807828997023018004378599828e+73', 0);
t('6.036649336201741152293032410301018575e+36', '6.036649336201741152293032410301018575309192634222268026610553981547335341134e+36', 3);
t('8.2206171209610808188838e+22', '8.220617120961080818883809546397772352053067497822e+22', 1);
t('357067001617476243862', '357067001617476243862.137169321', 4);
t('3648', '3648.935966276480770486703829', 3);
t('3667256', '3667256.14321901053142272931937401084036', 3);
t('3.06817804911202488565210058368288435840855617967301618918521966618918e+68', '3.06817804911202488565210058368288435840855617967301618918521966618918898694871236138832751471925640291008e+68', 1);
t('6.397956949401398212866287356127033102182339663673964891147500216e+63', '6.3979569494013982128662873561270331021823396636739648911475002160201253259767111914786e+63', 6);
t('4.035852629664930971748714986884026499248056376602e+49', '4.03585262966493097174871498688402649924805637660190057197207752443783928e+49', 0);
t('690938', '690937.205492020637017366344964341683031', 2);
t('4572785807971', '4572785807970.2685726', 0);
t('9.12591556752170002546686195712080775076927539494357342e+53', '9.12591556752170002546686195712080775076927539494357342095192221318809927523394869766948859999e+53', 6);
t('3.175166710121609964935909273257064925241534e+43', '3.175166710121609964935909273257064925241533921325823763693547e+43', 2);
t('8.6981262273677133498099001368854630216532260172495845284342e+59', '8.6981262273677133498099001368854630216532260172495845284341969645697018865379917639005276e+59', 5);
t('5.43909171309351447662743501782820255783778421662946112946990882360329e+68', '5.4390917130935144766274350178282025578377842166294611294699088236032838010825005751271e+68', 0);
t('9.784135122662915564368384002663201291592977201175859415877628841e+63', '9.784135122662915564368384002663201291592977201175859415877628841445610051468229986e+63', 3);
t('1.075926913120789044066114677747282911808323013538262852302400311648e+66', '1.0759269131207890440661146777472829118083230135382628523024003116470855e+66', 0);
t('24', '24.009013648289204609707762701', 4);
t('8.75619449783486902827580978677238339353807302997843705455206849896e+65', '8.7561944978348690282758097867723833935380730299784370545520684989674681468898373241422734005491e+65', 3);
t('49185', '49185.42432350042440262481433144719', 3);
t('475313129', '475313128.81802828668961', 0);
t('5.966160504823907616078866600887399441996553619375546697015e+57', '5.96616050482390761607886660088739944199655361937554669701500365941215e+57', 3);
t('8.67093818828233413993699849118457718482116385647241974416e+56', '8.6709381882823341399369984911845771848211638564724197441644559865e+56', 3);
t('4.018307218209746175224522445986860839987164456492973969349e+58', '4.0183072182097461752245224459868608399871644564929739693489418729882986617019584512013283e+58', 0);
t('4965078', '4965077.956955313373056935621', 2);
t('6.32074464844040699391589694212584145237969644385445479e+53', '6.320744648440406993915896942125841452379696443854454787303226e+53', 4);
t('2.630018093200468445909344327503187558812e+39', '2.63001809320046844590934432750318755881276774e+39', 1);
t('5.9845994166628691963626788515044007024791069617050073781932631068e+64', '5.98459941666286919636267885150440070247910696170500737819326310684179e+64', 3);
t('5.38788728618099476057660664795230746327516453731e+47', '5.38788728618099476057660664795230746327516453730723672718211491484463437612544615e+47', 5);
t('5.816680772652537833886113306215842146722035445468511689872171309392e+66', '5.816680772652537833886113306215842146722035445468511689872171309391615108203036895388894202315e+66', 4);
t('5.14951895405085032556822954571292087413665571538603148148092264951e+66', '5.1495189540508503255682295457129208741366557153860314814809226495101085411721086436447394e+66', 6);
t('9.38071154248816610903159656235010365e+35', '9.38071154248816610903159656235010365457924684058e+35', 6);
t('4.6192344120951390457511809260028977897911933273960342542075621554585705e+70', '4.619234412095139045751180926002897789791193327396034254207562155458570425292193318612e+70', 0);
t('895', '895.42468256229', 4);
t('4.49593629458007552251945193855124924788525290643178e+50', '4.4959362945800755225194519385512492478852529064317781769525204246314622e+50', 5);
t('1.57561665415364001696709e+23', '1.575616654153640016967093563564651371666e+23', 4);
t('9.5119206433900111282160111340222123761771472865509429834e+55', '9.51192064339001112821601113402221237617714728655094298342579e+55', 1);
t('2.8705511287442274153174451865706904160604287523337828148634483123671245935117e+77', '2.87055112874422741531744518657069041606042875233378281486344831236712459351170440769052264237721532651856136663e+77', 4);
t('7.34188971833045579480780836481104523190936e+41', '7.3418897183304557948078083648110452319093625282376588007189862745851161e+41', 6);
t('7.8608372491686434746950705553718082749885371792704000800225593187312714063278e+76', '7.860837249168643474695070555371808274988537179270400080022559318731271406327753488333027e+76', 4);
t('6.469775389199626982124099675993476e+34', '6.46977538919962698212409967599347606034988957766173192337753531700792e+34', 3);
t('5.8545430675082317385046601147591350320748593523353867726685748e+61', '5.8545430675082317385046601147591350320748593523353867726685748416216417718e+61', 6);
t('6253581', '6253581.49602122273536242131464028542', 4);
t('8.7344751925490789359100991e+25', '8.7344751925490789359100990700674856026086725e+25', 0);
t('3.9904601157326518550436849417943739334793e+40', '3.990460115732651855043684941794373933479342900084994082134338812305943386e+40', 3);
t('7.117509805619442000811625308308028306e+36', '7.11750980561944200081162530830802830605763083615357319229708510119793e+36', 4);
t('239', '239.6', 1);
t('6.583584600606673632872593433278933533220316054467200967095949640912736824225e+75', '6.5835846006066736328725934332789335332203160544672009670959496409127368242248629713e+75', 5);
t('3.695920981918849753532424768925832178720483413e+45', '3.69592098191884975353242476892583217872048341388978498358e+45', 3);
t('2', '1.3037831777620558701769453039973469', 0);
t('8.209369008504729502003611908929598068593e+40', '8.209369008504729502003611908929598068593e+40', 6);
t('1.7943552590764773563109836e+26', '1.79435525907647735631098360862158965291e+26', 1);
t('8.27389970382499192225882435e+26', '8.273899703824991922258824345580491438304434418276176349396745658e+26', 5);
t('462561608456627', '462561608456627.001777', 3);
t('8.1839600623408782869984730140049576888373907446562596320788904262169763785362e+77', '8.183960062340878286998473014004957688837390744656259632078890426216976378536205007147403782e+77', 3);
t('6.703769389175962220793e+21', '6.703769389175962220792067880359735732888123800491e+21', 0);
t('2.5585369539549659010966714135825828801369980436910644884291291e+61', '2.5585369539549659010966714135825828801369980436910644884291291234042228005022238e+61', 5);
t('4.71355729812843325551825190733754692238411906900564645150190008e+62', '4.71355729812843325551825190733754692238411906900564645150190007430239409925817447e+62', 2);
t('8.743778229459959593062156414403742568639029e+42', '8.74377822945995959306215641440374256863902836579411682005851e+42', 2);
t('9.4610942886126267215813230206813878133108628300770338213090890302608873805945795e+79', '9.4610942886126267215813230206813878133108628300770338213090890302608873805945795171504245711910393542869912e+79', 6);
t('9.637007602803820224674484773388404422058784394922216256468207851098e+66', '9.637007602803820224674484773388404422058784394922216256468207851097102844188166040233086965888060242247e+66', 0);
t('9.8929084923535343669756305730610829040131245900415500369e+55', '9.89290849235353436697563057306108290401312459004155003684864835083512265034512297039071425988079e+55', 2);
t('227029338743263', '227029338743263.93013322884665944911687839', 1);
t('9556', '9555.702815788750539915212443558755764', 0);
t('7.5777656953887385271106133131169037438362239623169e+49', '7.57776569538873852711061331311690374383622396231687000596e+49', 6);
t('6.682104529462952632410838e+24', '6.682104529462952632410837641372635268045881966538e+24', 2);
t('3.40490212059506016256377925738958571721640636153e+47', '3.404902120595060162563779257389585717216406361520888558246387332e+47', 2);
t('6.02441364429381327260741367276985467068046371110897032865165337e+62', '6.0244136442938132726074136727698546706804637111089703286516533653471194692722610656609e+62', 4);
t('2.5313651653786498793153255734290103587e+37', '2.53136516537864987931532557342901035878757668609321327884376561077398262963e+37', 1);
t('7.85665005570333663657093714469705934e+35', '7.856650055703336636570937144697059336863289133308185e+35', 0);
t('177640526141789', '177640526141788.343225172293525', 2);
t('3.720337371189052622074943e+25', '3.720337371189052622074942921963398883266421248541e+25', 2);
t('8.6313749672631505000804724190451538529154319985775036960071751534597975400579e+76', '8.631374967263150500080472419045153852915431998577503696007175153459797540057885204939257359487066282718539447e+76', 5);
t('6.0093917332950477604948831161021364170792508830154947009e+55', '6.0093917332950477604948831161021364170792508830154947009e+55', 0);
t('8.039856561515957202207593997063010720427567987067604601e+54', '8.03985656151595720220759399706301072042756798706760460081115e+54', 5);
t('9.04126850298381168011568888913120103322736027748100982152669106905664e+68', '9.04126850298381168011568888913120103322736027748100982152669106905663196e+68', 0);
t('32970', '32969.86013043774999017900493233800251808807', 4);
t('4.062501613145928449827898996803197068849565543663154887810367223956097172358e+75', '4.06250161314592844982789899680319706884956554366315488781036722395609717235882712303074126e+75', 1);
t('1.2585221051341615760113300656136097763123689416096518235274048137047508960225e+76', '1.2585221051341615760113300656136097763123689416096518235274048137047508960224444402424065809722365e+76', 0);
t('76428498', '76428498.00834040050622904', 3);
t('2969542081490470842', '2969542081490470842.2873874609960997776387424601', 1);
t('1.83915362194670915529649750389183e+32', '1.83915362194670915529649750389183e+32', 3);
t('9.051934488304764732260681809870433413368e+39', '9.05193448830476473226068180987043341336894274162300324775666234e+39', 1);
t('5.5055581168379212453472842196419487578340912520119781134168481302943305e+70', '5.5055581168379212453472842196419487578340912520119781134168481302943304427006511738950093684489283497e+70', 2);
t('7.8212509096600498185673448363795561801e+38', '7.82125090966004981856734483637955618009925616349415607657138464833290636076e+38', 4);
t('3.0546982208479323109313411268e+28', '3.05469822084793231093134112688982335665368647631e+28', 1);
t('48401191701190454916', '48401191701190454915.87020458175288248919360841887713552', 0);
t('2.112204187292732553586397374536644222038661332931779202378403e+60', '2.1122041872927325535863973745366442220386613329317792023784031e+60', 4);
t('2.32345597459570075584924011046569282105626864293765776e+53', '2.3234559745957007558492401104656928210562686429376577553656111494e+53', 6);
t('6.83768634613093432910405748169502361694478922e+45', '6.8376863461309343291040574816950236169447892199728904351925720243118213615618093e+45', 5);
t('9.750147130105570610532123362958045378e+36', '9.750147130105570610532123362958045378979179715926704377695369e+36', 3);
t('2.100861289861071804337e+22', '2.10086128986107180433695930143316811637333008279165590263448e+22', 4);
t('6.86043620730137169613692822530112725634606192506087063665162541409521357214042e+77', '6.8604362073013716961369282253011272563460619250608706366516254140952135721404168108626834814070528e+77', 4);
t('1.5626034555461789267637613119509784678795467574624046084113e+59', '1.562603455546178926763761311950978467879546757462404608411306911462258050600025152315054266e+59', 1);
t('8.1657953379518384767073891983969032e+34', '8.1657953379518384767073891983969032197860059203770678016940796429163e+34', 5);
t('8.76242761957079783283256884156570096310765263e+44', '8.762427619570797832832568841565700963107652628626208374880873465683235356e+44', 4);
t('5.738034559825558584827988487e+27', '5.738034559825558584827988486842333820461031439008871488489056012e+27', 0);
t('50057554472467', '50057554472467.164635378107751829995761049170916', 1);
t('2.217574620839810044488132284149156661898910087838684414107246055650497e+69', '2.217574620839810044488132284149156661898910087838684414107246055650497247127025575756749e+69', 4);
t('2.5599585974649223224327226161115338826053171794370023977e+55', '2.559958597464922322432722616111533882605317179437002397792613551347e+55', 3);
t('1.43014821461134396323079197376e+29', '1.43014821461134396323079197376075503936831895045225252422372849704547e+29', 3);
t('9.70966118807833422956644722296756129766012276425821843096979556875e+65', '9.70966118807833422956644722296756129766012276425821843096979556875029e+65', 6);
t('4.916533296743126969789915322e+27', '4.916533296743126969789915322e+27', 0);
t('4.833542905767501913532472382036762424309928346865656598315910513985992546e+72', '4.83354290576750191353247238203676242430992834686565659831591051398599254568346115e+72', 0);
t('1.3278316562805597179325e+22', '1.32783165628055971793246463003781572653917e+22', 5);
t('5.02347253856796475647466e+23', '5.02347253856796475647466193e+23', 5);
t('13871', '13871', 4);
t('2.25474388246375890069616800777e+29', '2.254743882463758900696168007764489438567545789666275279171902946e+29', 0);
t('1.02187732311006848174021155848981225371768135e+44', '1.0218773231100684817402115584898122537176813528139488791683036875150612463985e+44', 1);
t('2909342', '2909342.4238780677375', 4);
t('5.63252321267098810926174933800717e+32', '5.6325232126709881092617493380071648e+32', 2);
t('5.23553453532019073853926210509049935358952607844215638892068535879e+65', '5.2355345353201907385392621050904993535895260784421563889206853587945892297422658429e+65', 4);
t('5.0110191100309032508871028312215600979e+37', '5.0110191100309032508871028312215600979641138288229618389443889e+37', 3);
t('4.7961858399681660804352167135837851113655618745113e+50', '4.796185839968166080435216713583785111365561874511295798100202049598678690552e+50', 0);
t('3.6413072083209667611577984e+25', '3.64130720832096676115779843247079245446941280671681175325417221e+25', 3);
t('2.83439430931506652088137802242984878152446095843660682602522650389e+65', '2.83439430931506652088137802242984878152446095843660682602522650388696313157109743775816855708e+65', 4);
t('6', '5.41744405', 0);
t('58970028613730800', '58970028613730800.2199658574092832368454', 1);
t('8.20762797459327051824581448969093981355593722774039e+50', '8.20762797459327051824581448969093981355593722774038945867906329529223994172067097145347e+50', 0);
t('8.54193986164574247811915221884901109509511490395756e+50', '8.54193986164574247811915221884901109509511490395756892065295262422447820275645e+50', 1);
t('3.3671952204343650523723248544011797199532387566275400356721261e+61', '3.36719522043436505237232485440117971995323875662754003567212611293933424352567164847630936905281e+61', 6);
t('7.895956448206507301924101293638155629123626e+42', '7.89595644820650730192410129363815562912362670531791013157843487e+42', 1);
t('235550616880409704600', '235550616880409704599.127968573', 0);
t('8.8364345580061269808644472129329280653955e+40', '8.836434558006126980864447212932928065395496132878436651857e+40', 2);
t('3996478976343', '3996478976342.3856997029833631225762369936431', 0);
t('296155900738434400', '296155900738434400.6386716', 1);
t('1.1830481689411792598668e+22', '1.18304816894117925986685219229261257e+22', 1);
t('8326900056386534199', '8326900056386534198.6860278942553748883', 4);
t('3.83365199013301205515355243939508806561289907596528931968567685526298673e+71', '3.8336519901330120551535524393950880656128990759652893196856768552629867273321092962870965667105e+71', 5);
t('9.3791314705961013288090054954372609296202314274173493146043e+58', '9.37913147059610132880900549543726092962023142741734931460434755787852055214175662842408203865372e+58', 3);
t('7.53156457775671837805805213210009899583881e+41', '7.53156457775671837805805213210009899583881451963e+41', 1);
t('6222125', '6222125.947399497889116625442366736', 3);
t('27246516013451', '27246516013450.7612200898046', 5);
t('2.1129209994249240465962150114302405500377695274770604922397881331e+65', '2.1129209994249240465962150114302405500377695274770604922397881331046343270898071712446295912642e+65', 6);
t('1.646532833140068856832411079427771744265723063103019194344170396855795846e+72', '1.646532833140068856832411079427771744265723063103019194344170396855795846472772100605573093746166121081e+72', 6);
t('8.425479546282021948869850897780983270136048547e+45', '8.425479546282021948869850897780983270136048546926147755138e+45', 6);
t('2.233872046078596369134793158082187513760673304511868920359e+57', '2.23387204607859636913479315808218751376067330451186892035944859933718652677e+57', 1);
t('3.116405743404107847814732269205375396135221718527468694425449065691242e+69', '3.116405743404107847814732269205375396135221718527468694425449065691241869806095568074204631019012404933659e+69', 5);
t('2.062365631214868258839472996400163124440742356524760343620038100366519e+69', '2.062365631214868258839472996400163124440742356524760343620038100366518635685404679919e+69', 5);
t('7.50745541728415428434029959e+26', '7.5074554172841542843402995893059819526420896996212780022697e+26', 4);
t('7.24849752468097696916398838713364051520307862650612728265666514561056e+68', '7.2484975246809769691639883871336405152030786265061272826566651456105618100701083e+68', 4);
t('1.35176383329614606610756531319295678018782464936214748745e+56', '1.3517638332961460661075653131929567801878246493621474874550800287300195566470029016e+56', 3);
t('4.7152341392034704538023e+22', '4.71523413920347045380226220796263110674520711227447379291824e+22', 6);
t('3.11927423685004836840577039188891100297737718473721047017231325136894944596e+74', '3.11927423685004836840577039188891100297737718473721047017231325136894944595400105170201920293344231e+74', 2);
t('2.933400342567756418849544349581259968391617744e+45', '2.93340034256775641884954434958125996839161774380675440442887971748700867e+45', 6);
t('978080378597', '978080378597.2017', 6);
t('4.372210642064489328448661007253100863929888104582288453e+54', '4.372210642064489328448661007253100863929888104582288452571259872839821582026e+54', 4);
t('1.857581283508729657743503973029242776985316586148834e+51', '1.8575812835087296577435039730292427769853165861488346530185e+51', 3);
t('7.421813035238230409761595532233089939079148043727378221365519874e+63', '7.421813035238230409761595532233089939079148043727378221365519873463075894088208132266204031e+63', 2);
t('51860977367633', '51860977367632.92841245248', 6);
t('1.95284973709573510813936820783019996132821775350531973163592085e+62', '1.9528497370957351081393682078301999613282177535053197316359208517808968343594003206246753959887549e+62', 3);
t('6.9464859606048993902832501774806312749761412476825724988127422436981545662e+73', '6.94648596060489939028325017748063127497614124768257249881274224369815456613e+73', 2);
t('21129', '21128.947551940996938322', 5);
t('868214861041', '868214861040.7427436259995316', 6);
t('7.74918309357334474806682151708655686896e+38', '7.749183093573344748066821517086556868950832e+38', 2);
t('2.230431257587000243746564167163186447940405426320077e+51', '2.230431257587000243746564167163186447940405426320076383541377505288703330654e+51', 2);
t('6494555134286333798', '6494555134286333798.4', 1);
t('462', '461.59410222325557994522667', 4);
t('5.39024618638372653122483710077093421975991216013901874390338817595e+65', '5.390246186383726531224837100770934219759912160139018743903388175945025e+65', 0);
t('1.12532182738546905376329237437102170669599779470511645090705e+59', '1.125321827385469053763292374371021706695997794705116450907054172134550142e+59', 5);
t('3.601323497164902344681087151677942539149573539415387031319081234142241e+69', '3.60132349716490234468108715167794253914957353941538703131908123414224106980338319e+69', 3);
t('8.3500141350805991379256449644186334968168974724806389539568927554e+64', '8.350014135080599137925644964418633496816897472480638953956892755422515632060455336286e+64', 3);
t('5.401131445300570554896434535066508128e+36', '5.4011314453005705548964345350665081270950342624714457010875100354387132625661e+36', 2);
t('9.6338971507843956503609197751788e+31', '9.633897150784395650360919775178841334361839784e+31', 3);
t('3055045603560147538', '3055045603560147538.3515', 5);
t('1.0337875723141065649275067510790681222557486415834002e+52', '1.03378757231410656492750675107906812225574864158340024144131893262996852354157450707845e+52', 3);
t('6628586154', '6628586154.6', 3);
t('33', '32.373155518538415', 0);
t('360573130404', '360573130404.1772', 4);
t('2.600098587066400190213419659095053181377974125e+45', '2.6000985870664001902134196590950531813779741255420320463e+45', 1);
t('75065387', '75065386.98302833398157725347298017479752418', 0);
t('6.8963281585506360266597808464229207581611594829703695196321237700812792e+70', '6.89632815855063602665978084642292075816115948297036951963212377008127918992506071226e+70', 2);
t('9.28197726936724954894573282211104735760787482097421156e+55', '9.281977269367249548945732822111047357607874820974211559982916467270345710190773e+55', 5);
t('3.907918344492889760185116925702963410054303636244477844047e+57', '3.907918344492889760185116925702963410054303636244477844046640552136476663480363798160760359609745e+57', 5);
t('20390', '20389.50608970538326', 6);
t('169686499443647', '169686499443646.100053454', 0);
t('1.14751034435884033701335834374150193187852871899067496879575846043627e+68', '1.14751034435884033701335834374150193187852871899067496879575846043626932134782274903719229367322867524e+68', 5);
t('3', '3.371802754012374149032621660036326692709', 1);
t('6571532413631720476', '6571532413631720476.8387885238245530034497383', 1);
t('711645553194682', '711645553194682', 6);
t('4022796', '4022795.687', 6);
t('7.4520872837909058911068647601019387382029518098e+46', '7.45208728379090589110686476010193873820295180975587424115061e+46', 2);
t('8.03496111125697330071171956759554080088783440345e+47', '8.034961111256973300711719567595540800887834403452118760463608845e+47', 6);
t('8.55511850491578616176163093563708160895365268972005384027430492224050471255e+74', '8.5551185049157861617616309356370816089536526897200538402743049222405047125441939022661980752136356946774e+74', 0);
t('9.410089814611218259774585235e+27', '9.410089814611218259774585235484822e+27', 1);
t('7.7606205390697079697957946444343391883700844095450185e+52', '7.7606205390697079697957946444343391883700844095450185e+52', 4);
t('4.58994818214423764644807412616998882808679714838440424403030461797814893812e+74', '4.58994818214423764644807412616998882808679714838440424403030461797814893812342208878013e+74', 6);
t('2.352923246599896770944553256e+27', '2.352923246599896770944553255908913239e+27', 0);
t('6.57437044461257145907456386880266741220483546270538944188089263831541580968217e+77', '6.5743704446125714590745638688026674122048354627053894418808926383154158096821662727e+77', 2);
t('5.144471216454355074735516002140628838593038720756482e+51', '5.144471216454355074735516002140628838593038720756481881662e+51', 6);
t('7.55341561758734508030157277452437863273441605731555574e+54', '7.553415617587345080301572774524378632734416057315555740173241606524174749783e+54', 5);
t('4.354982111603472427964762e+25', '4.3549821116034724279647619493655447118997607358552409709e+25', 2);
t('6509325589913679', '6509325589913678.913617766383998659496023511512858', 2);
t('666281', '666280.13924571686833198933637667668112364', 2);
t('9.60199236890422200332350658058079087150429925358407963e+53', '9.6019923689042220033235065805807908715042992535840796342235866415544833610757e+53', 4);
t('1.62306671385880562700401146583371770207236387224456185716632e+59', '1.62306671385880562700401146583371770207236387224456185716632051105062492e+59', 5);
t('3.90349821730036455964772370048656246021974386995415e+51', '3.90349821730036455964772370048656246021974386995415033871223679e+51', 4);
t('3.895161261341522686895752632514847521825863076204798881839954312741e+66', '3.8951612613415226868957526325148475218258630762047988818399543127409e+66', 4);
t('6.25312627484320038802792129687993e+32', '6.25312627484320038802792129687992603074108932199032287019e+32', 2);
t('7.5312441243891577030062206881031743279845658681657662674e+55', '7.5312441243891577030062206881031743279845658681657662674103562801e+55', 6);
t('318581309743', '318581309742.186842979710587', 0);
t('7.50855745791198760171353157088272348952587600306034994135951635926213e+68', '7.508557457911987601713531570882723489525876003060349941359516359262129e+68', 2);
t('6.23597982856234075088091595070521511023354363e+44', '6.2359798285623407508809159507052151102335436295014681064614367149e+44', 0);
t('84322488230978019136', '84322488230978019135.2227356965742193995386131512728', 2);
t('16764', '16764.8665898588107088341937975401', 1);
t('8.18935827058262157249579209e+26', '8.18935827058262157249579208026965e+26', 0);
t('491791160034568602461', '491791160034568602460.83489923404591775163573', 2);
t('6.229504129470767563312789386745388612037820576806e+48', '6.2295041294707675633127893867453886120378205768067974267924876508095964334825746814e+48', 1);
t('1.208874896653745206039245186466009495535378043650030890890869246166106563569228e+78', '1.2088748966537452060392451864660094955353780436500308908908692461661065635692279595e+78', 5);
t('9.80626682576630111702042213110361224617656870277610076975453108e+63', '9.80626682576630111702042213110361224617656870277610076975453108044184252370387593526284191295431542542e+63', 4);
t('9.1613888774072527927195114711544852205567780437825695734193073459254248e+70', '9.1613888774072527927195114711544852205567780437825695734193073459254248529627314400484204661430178990453637e+70', 1);
t('673517021208', '673517021208.9520590811346224620465', 1);
t('488983444', '488983443.827', 0);
t('4.6337190267670232287172031071723722378294103664e+46', '4.6337190267670232287172031071723722378294103663127179388e+46', 0);
t('6.3139597581687527606169340957866e+31', '6.313959758168752760616934095786555041536228188648917605288037039409e+31', 2);
t('1.54184940885928055170683378871489428906271821461859385037189717e+62', '1.54184940885928055170683378871489428906271821461859385037189717286319190992985766786581164023647478686e+62', 6);
t('1.63191916991957661548524946828787075953112885078e+48', '1.6319191699195766154852494682878707595311288507800818816847603111640452525132673e+48', 6);
t('2', '1.173623567', 0);
t('52181901174680', '52181901174680.411663178526728847034927', 1);
t('1.4428724102781618642158162144368851918104e+40', '1.442872410278161864215816214436885191810322778115208449994477462682497831e+40', 0);
t('2.11079443220477721164615243276424047214227366133785871797501665832663e+68', '2.110794432204777211646152432764240472142273661337858717975016658326637343733212934e+68', 3);
t('7.01873743153639142702763253786592257300036204279037943e+53', '7.0187374315363914270276325378659225730003620427903794263281588858684437869318245e+53', 4);
t('297335892209058', '297335892209058.681131934803840285606124', 3);
t('8.248773121583558644485e+21', '8.24877312158355864448508e+21', 1);
t('4.28146436685796776936219858146868127921870561782487170316457881813318743106081e+77', '4.28146436685796776936219858146868127921870561782487170316457881813318743106081369565342945403698537616397552596e+77', 4);
t('9.9820005984048321058530905694335215253469647160852278493082995163703534074e+73', '9.982000598404832105853090569433521525346964716085227849308299516370353407378913408895725481e+73', 2);
t('9.148522784578220274278e+21', '9.14852278457822027427775281695859151371500029e+21', 2);
t('9.939519663839419097084309722114337860929618038e+45', '9.93951966383941909708430972211433786092961803758074876538411188673348e+45', 0);
t('632030633305048023685', '632030633305048023685', 5);
t('4076', '4076.17183659158963369847898', 4);
t('5.0915870680446042240788973434264033797234724711318458318825931704e+64', '5.09158706804460422407889734342640337972347247113184583188259317035179494921e+64', 5);
t('2.764391420260965121209440896051695682676356191890177e+51', '2.7643914202609651212094408960516956826763561918901765856732207162244848e+51', 4);
t('3.9447030166935777285149689808260893983776285e+43', '3.9447030166935777285149689808260893983776284915557532e+43', 2);
t('8.010340555613665231927395659663971527793424333051426839523457029297415808148e+75', '8.01034055561366523192739565966397152779342433305142683952345702929741580814831598882542203e+75', 1);
t('4.5925662338700879558086060238867215491730251801245149826509116719e+64', '4.59256623387008795580860602388672154917302518012451498265091167181660209345699020845019573551693665e+64', 0);
t('36504551', '36504550.50166831479470939986155470151861004', 5);
t('2.12540209018988712945893945069101074121688475e+44', '2.12540209018988712945893945069101074121688475323726090278554628156391087371545506904e+44', 5);
t('181125152', '181125151.99491757248404575757536635094871583', 0);
t('5.779523432816833924616772030412948003386911576895800096115162704042415963289556e+78', '5.7795234328168339246167720304129480033869115768958000961151627040424159632895565935151683005e+78', 1);
t('9.17826096990960792013134687632848447684591816754268192955e+56', '9.17826096990960792013134687632848447684591816754268192954583e+56', 4);
t('7.37421367532529067061667742667390536373826923290956e+50', '7.37421367532529067061667742667390536373826923290955104174785628111147170055463656e+50', 2);
t('4', '4.3686309345715094939913360017624432429', 5);
t('8.3594110965962381130596855916957925566323732058003739681143185743e+64', '8.35941109659623811305968559169579255663237320580037396811431857425404163e+64', 4);
t('5.8017462781868947979669035963150371455e+37', '5.80174627818689479796690359631503714551627518481e+37', 1);
t('1.90669137860811651611491585358014142495464234863436909519124432366465306869e+74', '1.9066913786081165161149158535801414249546423486343690951912443236646530686990503828136061620899505412969685328e+74', 1);
t('65827281', '65827281.952680368668829078', 1);
t('3.796975029309190153935073574227749285722909213685e+48', '3.79697502930919015393507357422774928572290921368440305490055258561431112182290578246e+48', 0);
t('7891207466205997', '7891207466205997.584874499696221437', 1);
t('2.94745525109421961698647322282990083780723298975940062387186332e+63', '2.94745525109421961698647322282990083780723298975940062387186331961089494759e+63', 6);
t('4.34282947014265862495e+21', '4.34282947014265862495e+21', 4);
t('9.1641692214618337763737436252361499553979881311255799266612e+58', '9.1641692214618337763737436252361499553979881311255799266611244928024975394877156e+58', 2);
t('5.864333650394800685281265896322e+30', '5.864333650394800685281265896322331612364407086e+30', 5);
t('7.48583556770321193530048004930689224512462576e+44', '7.485835567703211935300480049306892245124625769726886498025816e+44', 1);
t('537697', '537697.02142073166750345433592', 5);
t('6.746416112722632847560558595748474646323241803499729e+51', '6.7464161127226328475605585957484746463232418034997282515230110158271943e+51', 2);
t('348870466676427057', '348870466676427056.540210736720958044510813849897553858', 0);
t('12657090', '12657089.364186117157400260898', 0);
t('1.031300029476346901189374675983105405944047815464946132481100505e+63', '1.03130002947634690118937467598310540594404781546494613248110050480689644637863861125e+63', 5);
t('2.615472057019087907913471735667812386452505134772501355517041236227187e+69', '2.6154720570190879079134717356678123864525051347725013555170412362271865410294e+69', 0);
t('7.04165504077691457763479440814442249894246758944393488056686043599000962e+71', '7.0416550407769145776347944081444224989424675894439348805668604359900096153767456881719096558635e+71', 5);
t('7354818904551179123', '7354818904551179122.7014798901745046823977703675030620318379', 0);
t('854817485148361', '854817485148360.5714740113462989051407045497052073830764', 6);
t('47000805088498599710', '47000805088498599709.708437024062675608904338047', 0);
t('2.1766018980782941709650115665537351498889478677e+47', '2.1766018980782941709650115665537351498889478677028004204702111607312292840436359777e+47', 5);
t('7.8367301959920444880797359773949243636413420565977635106208263575374910713015704e+79', '7.83673019599204448807973597739492436364134205659776351062082635753749107130157048971635283591024e+79', 1);
t('3.08903346956401542864799535261274279172597713664198203701807794e+62', '3.0890334695640154286479953526127427917259771366419820370180779377521270933350292462773167787142e+62', 5);
t('576562571', '576562571.844608138306992462909059062174553', 3);
t('4.88885922847235829453662441295981179020690065850389e+50', '4.8888592284723582945366244129598117902069006585038897785761278e+50', 0);
t('805030', '805030.3196150823480264115976649255009294', 3);
t('3.75867227262935844604124624219765052177179e+41', '3.758672272629358446041246242197650521771793e+41', 6);
t('8.75150119113270892435492538833147019932204241197862490821051048044419e+68', '8.751501191132708924354925388331470199322042411978624908210510480444188669757061961455531943e+68', 0);
t('42601873172232953', '42601873172232953.30659313764825104206642999', 3);
t('1.8171003585956362231021760046143097114054128693433487680606690918875530579038e+76', '1.81710035859563622310217600461430971140541286934334876806066909188755305790370439773413227239119191673971090333e+76', 2);
t('3.71331955392433687189949e+23', '3.7133195539243368718994912855e+23', 6);
T.stop();
})();

30
test/modules/sign.js Normal file
View File

@ -0,0 +1,30 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('sign');
function t(n, expected) {
T.assertEqual(expected, Decimal.sign(n));
}
t(NaN, NaN);
t('NaN', NaN);
t(Infinity, 1);
t(-Infinity, -1);
t('Infinity', 1);
t('-Infinity', -1);
T.assert(1 / Decimal.sign('0') === Infinity);
T.assert(1 / Decimal.sign(new Decimal('0')) === Infinity);
T.assert(1 / Decimal.sign('-0') === -Infinity);
T.assert(1 / Decimal.sign(new Decimal('-0')) === -Infinity);
t('0', 0);
t('-0', -0);
t('1', 1);
t('-1', -1);
t('9.99', 1);
t('-9.99', -1);
T.stop();
})();

126
test/modules/sin.js Normal file
View File

@ -0,0 +1,126 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('sin');
function t(n, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.sin(n).valueOf());
T.assertEqual(expected, new Decimal(n).sin().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 40, 4, 'NaN');
t('0', 20, 4, '0');
t('-0', 20, 4, '-0');
t('Infinity', 40, 4, 'NaN');
t('-Infinity', 40, 4, 'NaN');
t('93332358216', 48, 5, '0.000816283943127306029649893248669685836695194145277');
t('766737078569022420173292205068953186848344673451240027655054631094318050', 18, 6, '0.00111135055272494455');
t('0.359136383962093189473162700700590970518456985109181875257764726415814563424613193774806585890478208084275468196568294033', 38, 1, '0.35146584650000000000000000000000000006');
t('3202222222227222222222222222222224222222222222222222222222.222222222222222222222222222', 7, 0, '0.5499568');
t('8', 5, 6, '0.98936');
t('0.15865555', 6, 0, '0.157991');
t('4.752', 5, 5, '-0.99922');
t('82315980453524767298085693995239044972', 5, 6, '0.18971');
t('9975666666', 10, 4, '-0.1932244457');
t('8111111111111111222222222222222.1118', 8, 4, '0.93383768');
t('1582389099446045988.444444444164077777777777777777', 3, 5, '0.145');
t('42.29499991999999919999999919', 2, 5, '-0.99');
t('2', 3, 1, '0.909');
t('225204831071708162873414430801935442203', 3, 4, '-0.367');
t('70387777777777777777', 6, 6, '-0.903662');
t('0.000009960105486531367489163480390414384530151948706557615588133070855712559603', 5, 3, '0.0000099601');
t('2.3', 1, 5, '0.7');
t('0.0369897655941305860082440964', 1, 0, '0.04');
t('93333333333.1111111113333335607254506018497853948241554833333333', 1, 4, '1');
t('0.81475726', 10, 2, '0.7275590895');
t('0.0020719', 5, 2, '0.0020719');
t('0.822309454290117043180146453820530722', 3, 2, '0.733');
t('811801481366184919659088.161679696898591', 8, 0, '-0.33739172');
t('82222222239', 6, 1, '0.85357');
t('0.671515352458', 4, 1, '0.6221');
t('0.1', 10, 2, '0.09983341665');
t('30.4507', 5, 0, '-0.82218');
t('82539', 1, 6, '0.06');
t('7904297312438003184', 8, 1, '0.88548151');
t('1555591677261255189013625216076301609467761280', 4, 4, '0.6012');
t('0.206', 5, 0, '0.20455');
t('47.85', 4, 3, '-0.664');
t('354522', 6, 0, '-0.432959');
t('57111.555555555551111', 9, 1, '-0.51645502');
t('5084117035723528870966332457.91693481159599044107', 10, 0, '0.5456651665');
t('66', 3, 2, '-0.0265');
t('4415133931290705273393593393689.69701970681754754956578240920056', 3, 4, '0.651');
t('4641', 4, 1, '-0.7628');
t('60782.222222', 3, 0, '-0.967');
t('9295.7', 4, 1, '0.2692');
t('660060.8', 5, 6, '-0.3736');
t('86', 7, 0, '-0.9234585');
t('0.867224365334893476015547423881141062327495194226274166759019810427983958472019', 7, 0, '0.7625362');
t('35', 9, 4, '-0.428182669');
t('6.4522', 4, 2, '0.1683');
t('74298341154961724283464838063126436742467617925325544', 6, 5, '0.381838');
t('98.9', 1, 3, '-1');
t('8719985534823285.8450271997', 5, 4, '-0.43915');
t('0.9528405', 9, 0, '0.815064492');
t('3007.440843', 1, 3, '-0.9');
t('8821000', 9, 3, '-0.999820738');
t('0.7244', 2, 5, '0.66');
t('223798525254185007541841321707204622.59819179923', 16, 1, '0.7304638404669184');
t('29832077939805655500490926756388', 31, 5, '0.9999881003434971787558628446047');
t('13555555555555.00000000000000000472565', 49, 1, '0.6767787926553990715415556952412713237217924208783');
t('899998709983400169781485597598985275361858454653904477166', 80, 0, '-0.9619682988852763093696947825524296540074948329137260856105387448568258894882118');
t('39826881720735191122621609200399853', 63, 6, '0.808868299975611790138921415253062939870563699821120858587818528');
t('0.005341982048471623278003226810889859381173803701969742990587783072822', 70, 4, '0.005341956641353734027312587021500975661701907307617983686735841700502311');
t('277.9997777777777716692059399741498679999', 30, 6, '0.999514190524582708045097875864');
t('61429536536284373.1373681766492167', 72, 0, '-0.987289391477952440400357263926723647295916567423922849613191038848150249');
t('7499999999909999997.909999999999', 71, 4, '0.34301339416705489181513042461845425762147177499632116466434976820897798');
t('349999995999999999939992999.92', 78, 4, '0.470719374558628137654141208065693026899676258865423797523069796274766223234845');
t('44510000000002060000000000000000.0200000008', 20, 5, '0.94842545081726504808');
t('62222222222293973777.555555555555577777777777', 20, 1, '0.97474440584787996681');
t('0.00000075952439582097539633', 49, 6, '0.0000007595243958209023709318824206298992320090760083707');
t('6466917226846635097989717000204.490981137498768', 23, 6, '-0.5067890798594245927272');
t('90000000000000007122', 12, 0, '-0.953061948465');
t('0.422029137363394323', 22, 5, '0.4096123952171808560627');
t('818.843', 70, 1, '0.8968883045810930941510638401062405075664719019866066309176929107557629');
t('30000000000000000200000000000003000000000000005.0000009', 50, 2, '-0.12313481713171373142907951990491671356466363502241');
t('975675853314022371079225', 48, 5, '0.880137190184686438889125592539968640170534430859');
t('0.00000066558889026', 77, 6, '0.00000066558889025995085640282676346670712623242127613563915036627009080674622220984');
t('69299999.9999999999999', 46, 5, '-0.3462252058608000475638742067375334366431550575');
t('8111111111267488711.9286432453434826269588597', 62, 4, '-0.99113853372157352283292183868051054140090305817866106070973511');
t('82', 71, 0, '0.31322878243308515263353199729481870255069002611658346075413062493460387');
t('488826170909042284127242210428971', 76, 6, '0.8995289099301142050732477297866877720021805553317366849920338096104233105207');
t('9092229227242222522222222222.66', 18, 0, '-0.935465793019682237');
t('5805959970379373082098495883210891370.0067111', 46, 6, '0.2201197700332631564419599177639647998475543596');
t('926600000000000000590', 41, 2, '0.81228550764810620054247659502626219692234');
t('619490746366110587736593084360', 65, 1, '0.21194121003724604936564767272815880572843184525364715905320674006');
t('5473424', 25, 0, '0.09262060997310434002923837');
t('5666666666666666666666666666666666666666666666616666626.6666', 87, 4, '-0.977239495645491722400759456250446932597508047794151805593705662875402907345001472700784');
t('499999.99999899999999999999999999999999999', 78, 5, '0.177832185579176104658571003320627225266903968719990210539163985433843099469721');
t('900000', 117, 3, '0.316282026370992050734738815532587276379228020456998295610327862506624971973233544404550831654146703508761520381016242');
t('83027766684462236825322.62114650623171519639122521318', 12, 4, '-0.476316326483');
t('925910897623', 129, 5, '0.792868652237225000804927754028414838623611710010734993138551247754919869022556217868513568705036768423332287103460206126685907362');
t('2918961308828646648994639730677467564302490828837720043486456401538236854705425586479512418277497121841759061091363', 23, 0, '-0.80586906475943044297492');
t('800000000000000', 13, 2, '0.9931677199759');
t('18400003.16100000000000032', 8, 6, '0.27307495');
t('99.999999999999999999999999999999999999999999999993', 63, 4, '-0.506365641109758793656557610459785432065032721296693555549406261');
t('20694757397464803355324887435556580472151471', 24, 6, '-0.0958707304545699270391254');
t('333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333335', 171, 3, '0.999861104212610844432827649084650490692662683912806434297051730891484017620891490814751729807506108594451118885277110368312661669230716203945478379798471281336247356157603');
t('22011131111011111.111111611113111111111151111111', 143, 2, '0.82582504036277799386306063085803210583251158969990606609364360685569588545519071481543672724620118406694191888115120286393881609546697317692404');
t('996270725099515169352424536636186062915113219400094989.8763797268889422850038402633796294758036260533902551191769915343780424028900449342752548782035', 46, 2, '0.6613706114081017074779805460666900787572253475');
t('0.780360750628373', 37, 5, '0.7035358359376557390803090830882458906');
T.stop();
})();

125
test/modules/sinh.js Normal file
View File

@ -0,0 +1,125 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('sinh');
function t(n, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.sinh(n).valueOf());
T.assertEqual(expected, new Decimal(n).sinh().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 40, 4, 'NaN');
t('0', 20, 4, '0');
t('-0', 20, 4, '-0');
t('Infinity', 40, 4, 'Infinity');
t('-Infinity', 40, 4, '-Infinity');
t('-0.01117212161', 7, 3, '-0.01117236');
t('-0.01', 3, 6, '-0.01');
t('0.4855939', 4, 0, '0.505');
t('-0.35', 4, 6, '-0.3572');
t('0.595', 3, 0, '0.631');
t('-0.7', 10, 1, '-0.7585837018');
t('0.477765550220420530146451989244265', 1, 5, '0.5');
t('-0.6', 4, 6, '-0.6367');
t('-0.7298937853748771062243', 8, 1, '-0.79645001');
t('0.6654323353551357716363059061801908595169', 9, 2, '0.715640069');
t('-0.822057582744136479779814788208915217619870720324021379213318423992919063068', 2, 6, '-0.92');
t('0.930187069407449026594918410064', 8, 6, '1.0702517');
t('-0.71551536', 7, 1, '-0.7781501');
t('-0.02477', 9, 2, '-0.024772533');
t('-0.5092804474897748330778251373356860713', 5, 3, '-0.53159');
t('-0.88527349524064252', 7, 3, '-1.005523');
t('0.92', 1, 5, '1');
t('0.9', 9, 5, '1.02651673');
t('0.01952', 4, 6, '0.01952');
t('-0.7', 6, 5, '-0.758584');
t('-0.9367', 1, 4, '-1');
t('0.713075', 2, 1, '0.77');
t('-0.80641', 4, 5, '-0.8967');
t('0.1', 7, 3, '0.1001667');
t('0.742', 4, 3, '0.8119');
t('0.19164777', 8, 5, '0.19282309');
t('-0.959128669199452184605687414702700501745933588051855', 5, 3, '-1.1131');
t('-0.82', 3, 5, '-0.915');
t('-0.54', 3, 4, '-0.567');
t('0.6187', 9, 3, '0.658934392');
t('0.5', 1, 1, '0.5');
t('0.1713', 1, 6, '0.2');
t('-0.09', 3, 2, '-0.0901');
t('-0.149', 9, 4, '-0.149551937');
t('-0.54', 1, 1, '-0.5');
t('0.5286', 2, 5, '0.55');
t('-0.2218560302782240024444484', 3, 1, '-0.223');
t('0.4206503074024213359239066760263937373', 4, 3, '0.4331');
t('-0.90343297229335446769185848339321460217', 7, 6, '-1.031443');
t('0.29824', 3, 3, '0.302');
t('0.970160998338313076097814326701945459022', 8, 2, '1.1296736');
t('0.9', 1, 5, '1');
t('0.66968', 7, 6, '0.7208699');
t('-0.73978789', 4, 6, '-0.8091');
t('0.4', 1, 5, '0.4');
t('-0.33319', 2, 2, '-0.33');
t('-0.05094763', 6, 6, '-0.0509697');
t('0.147', 2, 4, '0.15');
t('-0.7521', 3, 1, '-0.825');
t('0.966', 2, 1, '1.1');
t('-0.2', 6, 4, '-0.201336');
t('0.3', 5, 6, '0.30452');
t('0.2297417916367587719174729947877594919', 4, 2, '0.2318');
t('0.7409761', 8, 4, '0.81066696');
t('-0.09', 9, 6, '-0.0901215492');
t('-0.18', 10, 4, '-0.1809735759');
t('-0.5', 74, 0, '-0.5210953054937473616224256264114915591059289826114805279460935764528022509');
t('0.949452626313209516617699142908712', 60, 1, '1.09867096195815727081614237630458180228025051136935234032153');
t('-0.82630505', 54, 4, '-0.923598615474838199854541207197320474034631988093767029');
t('-0.14360721351237246987568757034881684526233784917328314', 51, 6, '-0.144101325429405622590434840215545338787652919410578');
t('-0.4733', 23, 1, '-0.49116986771004112197472');
t('-0.5044771449885283269', 58, 3, '-0.5261490899404374562669581230733559491094381606214659786475');
t('0.5292602', 35, 4, '0.55431766127533774367181438483674235');
t('0.3540955931426128907807', 61, 2, '0.361541756843620905162708539502960691569195176490187925093063');
t('-0.10396270844781004445623314451335288', 42, 5, '-0.104150085412880845209759850184027732716498');
t('0.34005327', 75, 6, '0.346645013173896201527795410362292912629770127776147273389479491565524413729');
t('-0.465', 56, 3, '-0.48193954184873018412767665045542782421613788403587256476');
t('0.6', 31, 4, '0.6366535821482412711234543754651');
t('-0.5481208052771', 80, 6, '-0.57598196281877562249156649817140676025943322140952007665313949431943795521753859');
t('0.4658', 43, 2, '0.4828277558817488705330396156695883903876349');
t('0.658924', 67, 0, '0.7076519258213409489258117150888493713909348882371351431016717177769');
t('0.84095', 76, 4, '0.9436339889105945408359964397732399439736824767663826815978864604057978720873');
t('0.1', 42, 1, '0.10016675001984402582372938352190502351492');
t('-0.546469309180216992488477103741682161392', 53, 0, '-0.57407689286989186234869758011224724765162964238150871');
t('0.952940960228', 79, 6, '1.103860008709590589328393540207693314047991810042822431557364905168130459211928');
t('0.5412557', 49, 6, '0.5680730254090400844499466841744626100138640781665');
t('-0.4', 48, 2, '-0.410752325802815508540210013844698104353150924363');
t('0.40959', 40, 2, '0.4211388569626912767627807558369832974574');
t('-0.2071333563131394184890351', 55, 5, '-0.2086176863728173404729808287424406991153510048007845957');
t('-0.006158312564838233045293421864257772700745093081', 113, 5, '-0.0061583514903881113191917490082260881905532636435605944044826372766861550655521768577200191192576920019205813951089');
t('-0.94735419679918088022811807376056681040587805226146', 33, 0, '-1.09555590192578368678418405664044');
t('0.3858706779532718096507434549', 90, 4, '0.395517999377232409663582197928235951630498131157951753386415315480929149180554295455429916');
t('-0.54290785843486103750513205980437253195531977198208721625688182147166538076323037457917540157093128639', 47, 6, '-0.56997393244891117340616510127151254831177604424');
t('-0.557397920603136432530648049076469730271228686196969657', 23, 0, '-0.58671285120863734551043');
t('-0.116426108886043214339286002636572559104915423316062689133928015970375', 86, 0, '-0.11668931394827265385287124886310892715353176113654298509501455004648909379387424934137');
t('0.20004668', 65, 4, '0.20138361947662140883950941306502243833641683553233187922633602303');
t('-0.72854338143449469754924045207742119688876235959260851289818192195120823675633348027917164866022227116150939180735340401518132565983221327345338239572304554973', 57, 0, '-0.794724373946660205913430120299005955752529862100864743743');
t('0.7075348682409645', 33, 3, '0.768062858516298468179764221964258');
t('0.9656450627407202186276140853108319189098662197785614356229', 112, 6, '1.122871917243193329250848114954520140832952763020717131988745064541821469254295854275194543068093878175092993757');
t('-0.3074887163636747690696589824464611540801585', 75, 5, '-0.312357149174629557268287563048266380887783749410576774474545432310552964774');
t('0.35414105198707877919833655237627933385061464419', 75, 3, '0.361590095862779887666259058403870675910577905319211259160227815980416737104');
t('-0.22861250504316830507', 15, 4, '-0.230609070338079');
t('0.3531311134837489181774304448792305788668900001541312879645273208393370689493465894263207269785178211563373399080451907494623164005742217451839584169072958609799133150259273', 104, 0, '0.36051634575023901465038196038262241500129988486533222911437937013660152976667815350655235742420924031229');
t('0.04434967092552732411292905', 99, 2, '0.0443642108672289452509083305837598955470962269229557910757510910026528522969230426477915847556546583');
t('-0.20001290733229792426683137634566153903', 21, 4, '-0.201349168898446405328');
T.stop();
})();

547
test/modules/sqrt.js Normal file
View File

@ -0,0 +1,547 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('sqrt');
function t(expected, n, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).sqrt().valueOf());
//T.assertEqual(expected, Decimal.sqrt(n).valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', NaN, 20, 4);
t('2', 4, 20, 4);
t('0.1', 0.01, 20, 4);
t('0', 0, 20, 4);
t('-0', -0, 20, 4);
t('0', '0', 20, 4);
t('-0', '-0', 20, 4);
t('Infinity', Infinity, 20, 4);
t('NaN', -Infinity, 20, 4);
t('NaN', -1, 20, 4);
t('NaN', -35.999, 20, 4);
t('NaN', '-0.00000000000001', 20, 4);
// Test against Math.sqrt of squared integers.
for (var i = 0; i < 500; i++) {
var j = Math.floor(Math.random() * Math.pow(2, Math.floor(Math.random() * 26) + 1));
j *= j;
t(Math.sqrt(j).toString(), j.toString(), 20, 4);
}
// Initial rounding tests.
t('11', '101', 2, 0); // 10.04...
t('11', '111', 2, 0); // 10.53...
t('1000', 999000.25, 3, 0); // 999.5
t('10', '101', 2, 1);
t('10', '111', 2, 1);
t('999', 999000.25, 3, 1);
t('11', '101', 2, 2);
t('11', '111', 2, 2);
t('1000', 999000.25, 3, 2);
t('10', '101', 2, 3);
t('10', '111', 2, 3);
t('999', 999000.25, 3, 3);
t('10', '101', 2, 4);
t('11', '111', 2, 4);
t('1000', 999000.25, 3, 4);
t('10', '101', 2, 5);
t('11', '111', 2, 5);
t('999', 999000.25, 3, 5);
t('10', '101', 2, 6);
t('11', '111', 2, 6);
t('1000', 999000.25, 3, 6);
t('10', '101', 2, 7);
t('11', '111', 2, 7);
t('1000', 999000.25, 2, 7);
t('10', '101', 2, 8);
t('11', '111', 2, 8);
t('999', 999000.25, 3, 8);
t('3.7', '13.69', 2, 6);
t('14.8', '219.04', 3, 6);
t('3.578708384438441', '12.80715370085', 16, 6);
t('49.56954417823', '2457.139710037', 13, 6);
t('4.9808503290100979', '24.80887', 17, 6);
t('54108953.7650348268963935650889893674872', '2927778877546676.5690784769302', 39, 6);
t('1.0000000000001', '1.000000000000000001402', 14, 2);
t('18.000001', '324.0000000000000000000008467', 8, 2);
t('11.00000000000000001', '121.000000000000000000000000001944', 19, 0);
t('2.00000000000001', '4.0000000000000000000000000000000005485', 15, 0);
t('7.1', '49.00000000000000000000007338', 2, 0);
t('19.00000000000001', '361.0000000000000000000000005645', 16, 2);
t('1.0000001', '1.00000000000000000000000000000006986', 8, 0);
t('30771277.0274560007853901874282412', '946871489900441.411712749999999999999999999999999999999999999999', 33, 6);
t('668.093253221434649746', '446348.594999999999999999999999999999', 21, 5);
t('0.9999999999999999999999999999999999999999', '0.9999999999999999999999999999999999999998', 40, 5);
t('0.9999999999999999999997187097975391240474677563824', '0.9999999999999999999994374195950782480949355918890297218761543222489261', 49, 3);
t('0.0000000000000298840312673111495324166498096924391126062701', '8.9305532478563043E-28', 45, 5);
t('0.0000000000000000000000000000000000000000025385115498645', '6.4440408887956349899441566682289191111111111111111111E-84', 14, 5);
t('0.0000000000000000000000000000000000000000000000000000140471526414353053458592377645343274655348630930173397', '1.97322497331782876158645511100784258994087355048761111111111111E-106', 54, 5);
t('0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002598902022257132166703490111187879281161770014282895', '6.7542917212922111E-232', 52, 5);
t('0.00999999999999999999999999999949', '0.00009999999999999999999999999999', 30, 1);
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('2.381905579721376621997401692376763128098896247600842643458999047531881813e+2763945', '5.673474190707827242511954659916889896808177096292E+5527890', 73, 6);
t('1.55701854242008e+46782286', '2.4243067414399499211289451653514095936017185263165775841595802781681024396317601E+93564572', 16, 4);
t('9.9154007211093362846141108573489066595648018e+35533561334', '9.831517146017554599160038642659577233621137326296138739740339E+71067122669', 44, 0);
t('2.233685316997e+25', '498935009536979677258304315852850344980736298107223.17', 13, 4);
t('5.6790521336e+45232', '3.2251633136582109206181686755297199980106981532535904612E+90465', 11, 1);
t('9.6241485526139652228166208472049625290167818011e+1987400693503696', '9.262423536278148172467483107114956962585715251496115897712401E+3974801387007393', 47, 1);
t('4.86348548114065869236934236337303e+2212121902', '2.365349102526598437724926901530502896022219085536E+4424243805', 33, 3);
t('8.94274851486936491099499873074488855754871805417147437494613942878964986078571e+3335853085908', '7.9972751000198231728604329670070818587227114744864529357097524020E+6671706171817', 78, 6);
t('2.0885911135683898927279398736031752344015545504649127170644896370353379e-4', '4.36221283967684692666426416376714916311505871923000872592271965E-8', 71, 6);
t('8.026722039667633182260408511913520451120702453123749778e+1023704129', '6.442826670208612947748038374549405718510075898758412768822080597099708051296751984704859E+2047408259', 55, 6);
t('2.460787425752332228460163766079909e+3858273752019344', '6.05547475474079E+7716547504038688', 34, 4);
t('4.4571175021534285e+429190', '1.986589642800241768950253744134264443767020159900398126805300834E+858381', 17, 5);
t('9.4527e+117835031340212', '8.935356909E+235670062680425', 6, 1);
t('3e+4904361806', '9.24E+9808723612', 1, 5);
t('1.957204568476697755184197782894827661216187868664840919284816726085640525e+438', '3.83064972286605667223095591399211128840797098184470613547390920507003215236913837823828877362E+876', 73, 0);
t('8.3032395380167e+34528872', '6.89437868256825998885730788226521728356623423193748251E+69057745', 14, 0);
t('8.39e+1711992', '7.041883770880118425878239862595091826896816E+3423985', 3, 6);
t('9.790699916656927140739512410042075323596621289368295024430694756362358e+1202', '9.585780485802596005974448193E+2405', 70, 2);
t('9.847056990214885399626178374025660624889212963684855438227064306989910207e+269432', '9.696453136853983765292198202484493417225363497463637965E+538865', 73, 2);
t('1.7359099425e+2747', '3.013383328415989492093650804382794630962008467500528389245351791E+5494', 11, 5);
t('6.834069539249451103168749378990917542555757999511237679195e-204174793001024', '4.670450646729720489233321886824609831695025907588563949E-408349586002047', 58, 4);
t('3.138284384168760310983231869196862541278664719980474337283125219910900471e-34848021177070', '9.848828875917495153223800564466445801240606621764417514110475E-69696042354140', 73, 0);
t('4.00929156084328544059400729461e+7547814714', '1.6074418819849188E+15095629429', 30, 5);
t('9.385699983e+163', '8.80913641710599005691978950691155189458746110141164551755555797229303947815057725607373E+327', 10, 5);
t('2.064258493001581567732632230025244966622767522065920193424751662709921e+4395', '4.2611631259291605782486841695067759569661374268622981237845E+8790', 70, 0);
t('2.2215318528416409230049e+218258', '4.93520377319001414151248980920968837885642082455528005489000815E+436516', 25, 3);
t('5.1330527926591638410946628719813202245977800293e+46304917529689', '2.6348230972226040854267304152051578667034961411058694242668334095640189241199450266226838E+92609835059379', 48, 0);
t('2.3253579055706672e-196', '5.407289389E-392', 18, 6);
t('2.503e+176755402701774', '6.2667203408185268363604194770009720671739738664656179598783769617970284596514793072E+353510805403548', 4, 5);
t('9.6369204975569156895116858673802898447044593766985526107265769189051484968e+360924246678463', '9.287023667623263145602226199798895429249583886386354524632320596574924425720535087689428938434E+721848493356927', 74, 3);
t('4.65424913912969424744230257268e+92793524825107', '2.16620350490895E+185587049650215', 30, 3);
t('6.01309285636782899752364197007684920017398969437949e-1790', '3.61572856993018165706134046141609828036662065978484170009821375392882703132369124228069E-3579', 51, 1);
t('9.509773153923080543680696577222501710491282865e+412437011050', '9.04357854390761345545547419189409265295580849E+824874022101', 46, 0);
t('1.257819302229712520962174337277372176639810260661e-44311330', '1.582109397061640889607372828919871087547023353618955613E-88622660', 49, 1);
t('5.60801706098533725826615935476591733e+4703349458', '3.144985535630261990939138487693918541845307202896600571E+9406698917', 36, 6);
t('4.520612769066843919448985334359993005870337091660370281988247839555503e+33279', '2.043593980785019831258664920277034009002215803890866800625E+66559', 70, 5);
t('3.9031901238112199422244215131891752614639270293050848390039e+24964497874732', '1.5234893142617446461800063194E+49928995749465', 59, 1);
t('1.67399696850587052605991771251848e+43519462757', '2.802265850566844477905639463307E+87038925514', 33, 2);
t('9.5408249368370749687627590642478e-80750', '9.1027340475372175567247E-161499', 32, 4);
t('2.4283599683e+171849', '5.896932135288822595493869E+343698', 11, 0);
t('2.1e+498604095779994', '4.2961949068353E+997208191559988', 2, 0);
t('2.20453501e-357801904289', '4.859974646744411255356204868440980E-715603808578', 9, 1);
t('5.8147365156793540374533779611537425212e+496502126799', '3.3811160746774874681847190789838042E+993004253599', 38, 4);
t('9.6614424956e+33826', '9.3343471095787978641040077990615E+67653', 12, 1);
t('6.840414600748481921789126213883996657219910998072878638534975744655859056193334e+365397755685166', '4.6791271910133013331845019336634770531377970763582548051313437429709245928538732275037320149E+730795511370333', 79, 1);
t('2.4239992207971581775833393874986290518e+2157096700', '5.8757722224252300019927334806719E+4314193400', 39, 2);
t('8.2220388454970543626652913918343189618675218734756075784049153881385219e+3', '67601922.776862534581068550153256371638256888653847213492979247915305924432354685660', 71, 6);
t('1.64244486917406282584413656933972205192398555455095912262410121870819135e+9340508786387', '2.6976251482762043514129832714354246217401306620466914174989739297066373978821E+18681017572774', 72, 5);
t('9.79090692715782911695847092370781210596001172136e+3115677438', '9.586185845626716371804688230667770283863635486094832181975090257E+6231354877', 48, 5);
t('1.944278705796582640753477900250165813717781441628885212874406345152815184e+2116000927238534', '3.78021968581403435601384837583880755915455510843E+4232001854477068', 73, 5);
t('4.8812606303344129781885860648384540427484823894462977105e+44750108717', '2.3826705341252710709297819787306105797004429874259653221553023657650287E+89500217435', 56, 3);
t('1.93086613186193490703915304629355648384e+4', '372824401.9171471', 39, 5);
t('3.1595298775034276812747891834935798726890112101053025250708e+161894746', '9.982629046836824729046499174522512414789196378588531892708638648812537073974580E+323789492', 59, 1);
t('1.390343871134044306144904825487640471083e+45251442', '1.93305608E+90502884', 40, 0);
t('2.96906709876922593571912431731393589808133769511469663747755797342953511989756e-481589284892170', '8.8153594369939084379355385E-963178569784340', 78, 4);
t('5.06340826804083097846774064356525633462189965902266516580957088231376938e+37447664404211', '2.563810328886424765192984306061855294460082173029294221865432386446793287430868E+74895328808423', 72, 6);
t('5.972915579625786738e+332753', '3.567572052133644795106468790474408870787279617581832818761015389739299185393099191398142701264032348E+665507', 19, 0);
t('3.13014348207873691395112227e+295812860174', '9.7977982184E+591625720348', 27, 5);
t('1.612e+29382080784098', '2.59549542566482274489688514562643282E+58764161568196', 4, 0);
t('2.21e+957', '4.88485916656072684684336288223350318510382769049147063964695662933003E+1914', 3, 1);
t('8.62822128158912829157811086596256560701532576e-8740918', '7.44462024840675394866139306388888378538969579877716771591568819584308250214770680342900129457E-17481835', 45, 0);
t('1.608973391338221287e+497446804197772', '2.588795374034416984035765330740978157904525653087970199E+994893608395544', 19, 4);
t('8e+3075307718', '6.892258379923950714603548436010577093809697037965095264743890886686628674142064667547853365035865E+6150615437', 1, 3);
t('1.7653932336326458078973623890876147360894729071996321e+26135', '3.116613269355929545695883758738082553843696E+52270', 53, 6);
t('9.256926799025012329e+345215572125607', '8.5690693762507461E+690431144251215', 20, 3);
t('5.03544006612282891778e+46195820165472', '2.53556566595150796637413433477866041357009510845074403852348490716635E+92391640330945', 21, 1);
t('2e-48295616097338', '4.896457515808248945640496172912496043632630141762245831365224969393680585716718487583992616E-96591232194676', 1, 5);
t('2.48878965963768168184605548022681e-363573591781789', '6.19407396991944743243101974561954532539988692605208840104874752842254662E-727147183563578', 33, 6);
t('5.3851648071345040312507104915e+740361058', '2.9E+1480722117', 29, 3);
t('8.3413437402428516353e+40', '6.95780153928886055351192302500612019875561321E+81', 20, 5);
t('2.79630657985938724890492968896027809909551e+913991292804', '7.81933048856490367778167731312448221121779492491922341813551588784321465352788E+1827982585608', 42, 6);
t('3.068981347405821994329370885223153147810167995e-134', '9.4186465107248546707630495330709378212295744168927053819144383155698062121265279905897752271E-268', 46, 5);
t('6.0271249500033e-10781347401', '3.6326235162953181809577645353279210E-21562694801', 14, 1);
t('3.199125028856e+25795', '1.023440095025536568635708921517360961793E+51591', 13, 6);
t('1.8666114157357738546399e+3', '3484238.1773551099774', 23, 0);
t('5.0973657635624059747024576803245965274249298527568449922667e+1692063437920', '2.598313772753815009002620426366701559965597345321262947368693172122554312019668885696226081E+3384126875841', 59, 1);
t('2.013328509206219057784323487222458501070404001508e-3238', '4.05349168598253649731512E-6476', 49, 2);
t('2.69875493659779856084765987819363578742030895189293632989705922592411229915e+4020061289691140', '7.28327820781098773E+8040122579382280', 75, 3);
t('1.6e+10', '2.56E+20', 13, 5);
t('2.3483542723023e+2733546344672534', '5.51476778824035712778945842083575307125895176285682237794763477393558870924644509568829084003207E+5467092689345068', 14, 6);
t('1.69575e+13', '287553939655483170302812649.82525337373758443', 6, 0);
t('1.32333278406215884733018366812891959496232303384e+8285944289080', '1.75120965737370433697922956385416755835455646442365E+16571888578160', 48, 3);
t('8.619857317385143165541404858165098391611310078189659021366304034052302190198e+423674679393446', '7.4301940172078196756317577124190795116444648589485897991299472748929474290863699960E+847349358786893', 76, 6);
t('1.5321135075443986e+3740', '2.3473718E+7480', 17, 3);
t('1.72340673782204014190446948179592390656068185428e+1299869167652256', '2.9701307839704062069609474255783085619215767002151887992880369960243164553E+2599738335304512', 48, 6);
t('2.6489093408250026638898665191805392071832816e+37475657', '7.01672069590995012448612570344661497015681231635520477773E+74951314', 44, 0);
t('7.552132321848183098292052759964393e+3', '57034702.6067040290231940776601570114357688435285519762590782006101866084636618667', 34, 1);
t('2.501915642047260445562789772566841521129383e+346367499153', '6.2595818799207554600051E+692734998306', 43, 2);
t('3.46410161513775458705489268301e+23505129984', '1.20E+47010259969', 30, 5);
t('5.5156817867298553573934377553326519175269141671462400489745247227004977385606e+2535798792', '3.0422745572463449598911698968741967861068325178395628338533947208549426458197501E+5071597585', 77, 0);
t('7e+413483559541878', '4.9446671019E+826967119083757', 2, 1);
t('2.3540150674351154530407163580243074454938968196e+2160300', '5.54138693771155115387408E+4320600', 47, 1);
t('2.737454074105672e+2878546', '7.49365480783773944781718916811056453166482639687697E+5757092', 16, 5);
t('7.454070919313777677e+2341606971625', '5.556317327015934668013876961309779446079811E+4683213943251', 19, 5);
t('1.1573376026021382616589933753247694e+358389221', '1.33943032639686490800430635561822376604163268393006414770600700814939E+716778442', 35, 1);
t('1.869736722457198060474037674032156648711972906521e+32904235983', '3.49591541130498529E+65808471966', 49, 3);
t('7.47395e+36118', '5.5859818323020679E+72237', 6, 0);
t('2.8316440369487011e+3', '8018207.9519871366038039483866918309675753055797380955099583126482331855373', 17, 0);
t('9.7472668692913041841429e+1309536008', '9.50092114211839024068782916975E+2619072017', 23, 4);
t('8.114992298209531e-2596906057289', '6.58531E-5193812114577', 16, 4);
t('6.703595e+401', '4.49381922866E+803', 7, 6);
t('9.7608119539308818711822517856627039556134970352903e+1249', '9.527345E+2499', 50, 0);
t('3.0066592756745816541757861126198711210412117e+139049925673', '9.04E+278099851346', 44, 4);
t('1.896015165815e+347585', '3.594873509E+695170', 13, 5);
t('2e+1005', '7.1236555794326143979309006340E+2010', 1, 3);
t('4.4721359549995793928183473374625524708812367e-2934', '2E-5867', 44, 6);
t('9.81380264259950340885274731932875646303790396039793934033661431416500117441683e+4610414097817', '9.63107223078929964397336E+9220828195635', 78, 0);
t('8.9376309368079848924360696e+36390757', '7.98812467625871776375673355260343E+72781515', 26, 2);
t('5.026652112874930197997606836236916458650894248379748587283939631792571414e+2570662179', '2.526723146387E+5141324359', 73, 3);
t('8.49293409e+2918903274734', '7.212992952916182126166161894531743826E+5837806549469', 9, 6);
t('3.7717367e+4831878', '1.4225997558149815433987209975829468787464264438709401098671706038917792294221101238217259236638882E+9663757', 8, 6);
t('5.65256722208745359096703556418756741838091330344004243880813554127204475354963e-196', '3.19515162002174718875005691558428708625371358895103E-391', 78, 3);
t('6.63236207127e+23317', '4.39882266444868312494846698153144297198308093870920987520682921E+46635', 12, 1);
t('1.0299091215176223197e+255', '1.06071279858520053783126987482987178921249572000906994047388785433323881546006E+510', 20, 2);
t('5.040737517733564457496704009949621179767208845752392579636770019086715865e+1', '2540.90347226867370536208924268972271855242897', 73, 3);
t('7.2998671170787362309999885642096413366997803441454046e-3', '0.000053288059927007419736192864488572091336455240976257828090775274140470718273556545610819', 53, 1);
t('5.11117005049595857693e+9', '26124059285086859749.111136068760', 21, 5);
t('1.89935540125106114644973371135677739395218e+49685', '3.607550940261579490044139098611195000453932161335896883380180003006836843018711910962E+99370', 42, 0);
t('6.18443052847326250790598455586e-2615403185', '3.82471809615120769875272018837130277169788007341654336023385958906492891E-5230806369', 31, 3);
t('3.426242491487763270227e+18', '1.1739137610476275565237282E+37', 22, 4);
t('2.96275501530970122781213e-3678', '8.7779172807427879568E-7356', 24, 5);
t('2.4428719e+4859', '5.9676230838955962140555831660429425584144796031304001629260382152102420202408466740096475145421788E+9718', 9, 0);
t('1.02832795192e+442784', '1.05745837668529806545913238826109255689541898043645621468495695830204838516639758771694008345342674E+885568', 12, 2);
t('6.514808353931537716266282122142219803851312224850046724512e-2045', '4.2442727888456152E-4089', 58, 0);
t('2.550511488760636812199575483724868e-1447172750541', '6.5051088543E-2894345501082', 34, 5);
t('2.4730609367420230671388e+12', '6116030396839332618454241.9526022655923587418704940810349550246004', 23, 5);
t('3.036323149912413372105696029126241615660685857583888271128260449310702453141608e-1349985', '9.21925827069403988819584961758405864669074310023419843237E-2699970', 79, 2);
t('2.6874987079843743011487811643134819286318198642391692062301e-91', '7.222649305417681173051748752199025762E-182', 59, 5);
t('8.8814616618312878350673062471290132392165769044e+163440250', '7.888036125057898099450298304157513376364713379776394983E+326880501', 48, 6);
t('8.003905394943370898574902868328421705723747639106911357526019275287081172297e+30146897', '6.4062501571203598084182532613957872182544E+60293795', 76, 0);
t('6.6869e+3882', '4.47141713850001280335127436138703209048665710727894216146638123448970973413333877E+7765', 5, 0);
t('9.46715778767100012677112937995161815357113020444e-327073528', '8.962707657665966551992881052251375867047729017714166968495362566E-654147055', 48, 6);
t('6.303431321113571e+275056324656282', '3.97332464199955790588897588438551310212027677784886403329179755857444550904597263134605E+550112649312565', 18, 4);
t('6.576174355328564536662125352346e+21602351976988', '4.32460691516810613850278067385309182411399820938966096E+43204703953977', 31, 2);
t('2.07630346262337137491871083e-3090618529044467', '4.311036068901801732099430365860481210539754465419778810616524065681770638162008279484055169E-6181237058088934', 27, 2);
t('4.2148890965989444057133600997628746172165814692968051092e-8712289445', '1.7765290096628665705861617573159354925958E-17424578889', 56, 6);
t('2.6474912249241999225341670266712257663525163332933359876990081330726543e+162573', '7.0092097860506405451155195833366486325362949236190817489245792816903602999857931117317190E+325146', 71, 0);
t('9.12874162316595732639551387628400033604695187619e-3', '0.00008333392362252263723524459', 48, 4);
t('2.7235179981923310319738235894879139608807e+1033760346', '7.4175502864775620583462352475547105037730945778584608279E+2067520692', 41, 5);
t('7.099057482524069554788222715721382261331093541531504796459e-5', '5.0396617140180980112290131689304401510152E-9', 58, 5);
t('9.10809918720977210707253937500924e+27380', '8.295747080405131128480935E+54761', 33, 6);
t('1.285681486112942019135229306830687883569187630472e+3834782', '1.652976883733583122E+7669564', 49, 4);
t('9.568088e+2018', '9.15482993151972E+4037', 7, 0);
t('1.987355257754938992377160858509897774952049248e+15', '3.9495809205262E+30', 46, 2);
t('1.9768903173746098651102397889231284119168749816365290144722209101587590107964e+46924932068', '3.908095326929485719118550903578424879636511190787119806290E+93849864136', 77, 4);
t('6.85223487409204247121078477321652642e+13', '4695312276972318913824783267.23915150099092256', 36, 2);
t('1.89753938328297503876364212659e+4', '360065571.110993325', 30, 2);
t('1.73793786659448789397819131927279578513780780522093623215e-26159', '3.020428028143E-52318', 57, 6);
t('8.6448435822785381294005301901316419084244682800468991364630579854249684e+199772394975', '7.473332056206242784465850133264347507502598072E+399544789951', 71, 3);
t('5.152189634588319893862857733009123865557155838508261990197856939965755e-21896842502066', '2.6545058030759325273618511956767499403152E-43793685004131', 70, 4);
t('6.363328661925045799106506614064522175879e+45790995', '4.04919516596767938142398731881702747229058975396741269844545638111172628708619095858703698307014719E+91581991', 41, 5);
t('2.809603385469e+3452', '7.8938711836403788689485387722739902228108362611929174E+6904', 13, 6);
t('8.387292474579902077507212611207840585e-13228993663', '7.03466750541446573370027044489E-26457987325', 38, 4);
t('1.8280039989118977381747692279217097e+2570948', '3.341598620037889427132828227624777069946213265099768868E+5141896', 35, 5);
t('4.242077070790137478716517628874194271194060827692514184105e+389854', '1.7995217874523433061846222162668474214071163108613415E+779709', 58, 2);
t('9.29961911573539491036147371e-27015695', '8.64829156977511683564833506322917189811629558525289718715023664251559870029893040656186008376212E-54031389', 27, 5);
t('2.9190392183495259081103419481759400578499514075079378347e+31', '8.52078995826261119108447319667254438902793796629435580E+62', 57, 3);
t('8.937227578505540103845413636584692573241532357433996111863e+1790938', '7.987403679E+3581877', 58, 1);
t('3.070283187058663486241563846238e+2571', '9.426638848735104E+5142', 31, 6);
t('2.8538810158098743e+3473261643654553', '8.1446368524E+6946523287309106', 18, 2);
t('2.008039e+36729025', '4.032219417259540272204478866331908221389931400048743477485727321671916860580259161402773798107E+73458050', 7, 6);
t('7.51692279236539994967372050974313334001215192497833104202e-2440875511683227', '5.6504128266382441683929602449473591619319549900002408802881702717481E-4881751023366453', 57, 2);
t('3.0435123169140879772323396228229690669146412039176588151e+8', '92629672232077598.90063863301233712326343840597041607655456994461', 56, 6);
t('2.236067977499789696409173668731276235440618359611525724e+702888559122', '5E+1405777118244', 55, 6);
t('5.97990172243658198399814740059437396277732066046e+370', '3.575922461E+741', 49, 4);
t('2.82561653740855466419452851014456248628635025976235076e-4280625271453', '7.984108816476710E-8561250542906', 54, 0);
t('9.48683298050513799599668063329815560115867e-434737', '9E-869473', 42, 5);
t('8.882e-4097945006776965', '7.88869662270039764413484643614524697066192137552471897225988700736686713038E-8195890013553929', 4, 5);
t('3.67889e+14891', '1.35342176496813904540880394246590582429142627731764911712414478149020053276032E+29783', 6, 0);
t('8.473e+456', '7.179707176136375341401913486978796960524639825994932608331410951477613527254629E+913', 4, 6);
t('6.061122e+156', '3.67371987435196618057562397883355060133829216965154000472540684500E+313', 8, 0);
t('1.2162592664785351757282744e-47741523717344', '1.4792866032949044394019E-95483047434688', 27, 5);
t('1.0226100780319713142530417271134325435661232545102289895560582934036408017e-3070736', '1.0457313716925544603251531895365106855371052455015295127376768840262251474879407584E-6141472', 74, 5);
t('6.40378773473547483807376041857055923862407e-289422539068310', '4.100849735154850424998568954883333023944579871020634818881424885849663612599045128003798737145657E-578845078136619', 42, 0);
t('5.1725935520949720972771088800926908173244154e+2824962274', '2.675572405517448082E+5649924549', 44, 2);
t('6.864734640020072049718705304013039739459327696999280834990366263684919488693e+28', '4.712458167789150819E+57', 76, 3);
t('9.4403813337678765859e+2275528598282', '8.9120799726952952463715474436836438839285693903355297048145204533165099122605783431631909389375E+4551057196565', 20, 2);
t('1.401091686602968166559525283171170204216e+4918493', '1.9630579142679499665419988066E+9836986', 40, 1);
t('5.76860337023413964786931e+2461399906291', '3.327678484307667442355379899894139310335808838737692146122103503686495579534E+4922799812583', 24, 4);
t('4.930871521981228238e+3437032097726610', '2.43134939662854741919117399694122150170471210277624540E+6874064195453221', 19, 5);
t('1.0245391862903256753964503966393139032236946080277416684518e-38', '1.0496805442444426583754480311188446871883996972187399715782318606844535332564E-76', 59, 1);
t('1.7128627267646388333852869565663674027391841238236919212997718917108311794e-4002', '2.9338987207395937897002373949538359655732613253567763605075447290049969107E-8004', 74, 1);
t('2.8264310169258223109845135255342978316223511737459003e-16767859699', '7.988712293440338047E-33535719398', 53, 1);
t('6.903495420085316148538509004607763967209023254e+44768102', '4.76582490151389356813825520590783598202999337271191949072678494086332063317360130E+89536205', 47, 6);
t('2.95564580436384800253055711281369395501536452408051186314e-203298238353891', '8.73584212085361806007883039348577463893244695975888298999502229344131381589611093355072253081E-406596476707782', 57, 5);
t('6.649283812592150138142528590709054870664998836855393073088808237856384012e+16918', '4.42129752204E+33837', 73, 1);
t('3.1418363802846828888954674287282088166631670326029874978921587241662126193072e-10', '9.8711358404803585142715995165965562371006E-20', 77, 0);
t('9.0168891708498077340870422538771763991860996900736805340459998564777522117427e+1646179540063', '8.1304290319388533208865555457549157885068286554112709492694227672649E+3292359080127', 77, 0);
t('8.977858829152028877e+40', '8.0601949156183038822620916355105579058051056436917994500749067325934920E+81', 19, 2);
t('4.2017305790590619e+646808528', '1.7654539859E+1293617057', 17, 3);
t('5.5524814508191389246383339131600308902340023710576826212458e+2497373294220', '3.08300502616906098687255826013116108848672731202638827475459671548604743541183982705838E+4994746588441', 59, 4);
t('1.67271971876579712062058760927597244127329496726295947385574838534557761275087e+4084885214', '2.79799125754792741188580781151558042045245397938161747962330378605256347960E+8169770428', 78, 3);
t('3.085527497069488331267423581241150396840258e+42246909', '9.520479935171901322697389268713897072458655100066709408989906359E+84493818', 43, 3);
t('3e+158107000193', '9.6977619149278219422781E+316214000386', 1, 3);
t('2.90723345116412399903677294614733205e+380', '8.4520063395676629612501328633225132880746874537228627270266E+760', 36, 1);
t('9.775891681481346189754834e-710', '9.5568058168056182185442353049791687180E-1419', 26, 4);
t('4.6646957424189037236e-233070856320311', '2.17593863693410473953572E-466141712640621', 20, 5);
t('8.53425633807185478645377489395742278102449403e+2105124743', '7.28335312439196245774226929758991441342086268907461367722377958885353595551884935516785591E+4210249487', 46, 4);
t('2.8161913e+30949787971256', '7.9309336869113277937283E+61899575942512', 8, 5);
t('6.6443937050711499376864490195641899272283176042527e+261607', '4.4147967707989123421155030572424236370263103192892052949087277363710E+523215', 50, 6);
t('3.887130387e+4462928527512', '1.5109782641945858394E+8925857055025', 10, 4);
t('6.9295847389150837205027607357674e-337585815724', '4.8019144653804829012013755178407300496433787057977746765392593580534900280159767925073E-675171631447', 32, 0);
t('1.67762269562204e+2724901494014124', '2.81441790886617380509520155082877145938117037134E+5449802988028248', 15, 3);
t('1.378806846317145211527751556938e+3615', '1.9011083194510316937617450165824777298618984876923310846235512081728267868E+7230', 31, 4);
t('7.2282380669809344745123929711647933739752741869853493e+129', '5.2247425552952276174806603769135304185149515310446734318136860424E+259', 53, 3);
t('5.112514728527103756119083043541744424478486522645230981812126003154941892e+920836812802990', '2.6137806849406565416963702733639313080984002961475E+1841673625605981', 74, 5);
t('3.15240118526970354837192462164291327592722e+12762', '9.93763323288983179604546E+25524', 42, 4);
t('3.49559682514708909727859773952360298460003998789958980573672291458393004e+132', '1.22191971639784089879E+265', 72, 1);
t('7.4813100457072356252346588698556564868296818103801416175589911024114791569995e+284130830840784', '5.597E+568261661681569', 77, 0);
t('2e-3768574628', '7.2713214641933444306829997615377506867292707248931E-7537149256', 1, 3);
t('2.902077e+1588760762', '8.422051691577715414082824473132488156131471218330734604226191089990683764449E+3177521524', 7, 1);
t('2.18935e-192883592280', '4.79327125880129020E-385767184560', 6, 1);
t('4.48463019222796485951602654336860567938893190030116242172e+473496', '2.011190796104263304745319026570265454712539877236299939E+946993', 57, 4);
t('2.546525295e+29021565225819', '6.4847910760149283558212070695669048254074329962785677108576986411961086444961000E+58043130451638', 10, 6);
t('1.51185657328663290102911156905e+18', '2.285710298190E+36', 30, 5);
t('2.6598141458335522206769057345931e-1022221889', '7.074611290376269E-2044443778', 32, 6);
t('2.1400246921846e+473622', '4.5797056831596035941207627491245833008597417378183068825736455247163834770170E+947244', 14, 0);
t('2.3774545577213805010498159234873880660721178e+422716', '5.65229017403016496862404612990739165210984813062645469906426138589591E+845432', 44, 1);
t('2.203089e+335', '4.85360341581551E+670', 7, 3);
t('4.910625878493595047710096578187419155296332340361665271615e+158478680481', '2.411424651853099211331932586857671419333629451402446313055708226355472325441681706664245120160E+316957360963', 58, 0);
t('2.14658304513912472592069256949618e+0', '4.607818769678757580622617058038482756337638794621523984131268073532516530956591238950305713306', 33, 4);
t('2.755609393656315990095837385538e-32204', '7.59338313040692946359911961843531565497832081882557075265876961832563840683131278114866271E-64408', 31, 3);
t('6.0796177733655821078861178138872182814062298888138e+13', '3696175227022267849032414092.016773404702311234937146358672775619', 51, 0);
t('9.322011536195057384357328326782263568235613559128e-24931530574', '8.68998990809537336703600486E-49863061147', 49, 0);
t('2.71986591529447641250156426872327014101855e+430301407', '7.39767059718065993935568543488443748452082512031990E+860602814', 43, 4);
t('9.748823047418070634441154844604945179095866321330356660832934187282699223e-3702188646680283', '9.5039550809869757481802467684142816071629587849671095519782938514286705E-7404377293360565', 73, 0);
t('1.878382903912616955109258360633381976169159358491282086149580414136009e+120243', '3.52832233371119558076316851E+240486', 70, 0);
t('4.621003503308429392531555236351223553159256034625873954713601722906751e+22257918209422', '2.135367337758877761572808626061137813597705703296648884770002410767354094917580791680252657855994460E+44515836418845', 71, 1);
t('8.09675556793333478408703745283365e+2697370827636895', '6.55574507268594587077340408367234333953545565465682867336894127238643198993462187195128E+5394741655273791', 33, 2);
t('2.02207593759537562422226807353364843462858518254559656e-28012230172050', '4.08879109740221741578687735602952948096051E-56024460344100', 54, 1);
t('5.3731000956898735111861968797250897647473152496311640907459600751218763861e+454513139585766', '2.88702046383025278824610014957155384890357084971884613239765424667693727485508799293067464689E+909026279171533', 74, 1);
t('7.6531546e-3210839', '5.85707760360226795537203615034919E-6421677', 8, 3);
t('5.1545158401e-849458529874', '2.6569033546401399505222840937237E-1698917059747', 11, 3);
t('1.362796e+820366697', '1.8572130578086568903670432137573555816173399866229650898073903609534634685E+1640733394', 7, 3);
t('1.803028018886897386311411e+392', '3.2509100368912099980074744E+784', 27, 5);
t('3.194063e+59854163', '1.020203979681842516145028680059578232774062730558684033505119017106807172711E+119708327', 7, 4);
t('4.261774950512222945050604e+766620941569952', '1.816272572881346033232615148233362658915452774043972856579675E+1533241883139905', 25, 0);
t('6.4982834054101674517e-6690629769341', '4.222768721702916271457625051478794776571420E-13381259538681', 21, 3);
t('4.63890650784339381668800704976722120910871991068098e+3684414202057', '2.1519453588511791178106435314081634243235207843258897805541E+7368828404115', 51, 2);
t('2.9151839322904732383444730694225e+30759', '8.498297359084546458280003048168914699436364769023695844300652045190667728E+61518', 32, 3);
t('2.766532719204307910633754595392000551442511483883250429903676087804405565590643e+455779478', '7.65370328642798200007936195028468256694001674934111932023715848409184276391931286002453021414093E+911558956', 79, 2);
t('7.15809196006477e+33292581643', '5.1238280508743809055025574209743282729559196766140070189951812797362009162E+66585163287', 15, 0);
t('3.86118619398318356259490388719113598185201634813542416e+406721231', '1.490875882460634284411863820052569490029137331918395153873776527023749083262931386830E+813442463', 54, 4);
t('9.689731193707917826178936968367758565636403e+40068362191', '9.389089060631627013431474273256976055318787324073601735849070341827498807062287216165E+80136724383', 44, 3);
t('2.380529012851904667362202911642711024107714e+198681597152426', '5.666918381029663696953608649066197933231308460645707103242820405560172691798118435135524461103430183E+397363194304852', 45, 5);
t('2.54746401587652656029608220458044130513888776543718542834122918527624080395488e+32532', '6.489572912185759966860293134205566227925787911969794771866E+65064', 78, 2);
t('6.92698673696026591387308445e+107400231637266', '4.79831452540234321937856594164763711E+214800463274533', 27, 4);
t('2e-3687675859352948', '2.87850545774362267882888183908800107382947760934094690201972229957797333658228601684365936E-7375351718705896', 1, 6);
t('1.618027041879108501297810734567701e+50804486666', '2.6180115082520583359185144823153085187283124373602323397858607127478347167082796349429269911729E+101608973332', 34, 2);
t('1.468859842402168586360692550046800918056478722e-36', '2.15754923662172353660E-72', 46, 6);
t('8.49215738290834886674655744364e+3929100150329', '7.21167370160847769931713219E+7858200300659', 30, 3);
t('3.080752255068078689981071323748588537107e-36384305560', '9.49103445710705218035789748393813719855362668161846E-72768611120', 40, 0);
t('1.173890248587e+32564710208321', '1.3780183157276814234744165885721310974270604540920153529405097095176115665588872141E+65129420416642', 13, 4);
t('3.3574798416124266047747707108073142426282137e-218933383480676', '1.1272670886833805240621800360101550017149869005946946591265232560766193937035542597E-437866766961351', 44, 0);
t('2.23944945243244996980913928295535257356722976e+3460351267', '5.01513385E+6920702534', 45, 0);
t('9.0144388862969379134e-45686027', '8.1260108434782378341695197333453540906E-91372053', 20, 0);
t('3.0154321001794005197296683806041624213563546270536367710423e+100086943546', '9.092830750792350171931235260936892651832323052358883721226795146110156733755114783658E+200173887092', 59, 6);
t('2.44369944036062486685492557249769572445990273975135928852505135432044491079041e+3973481', '5.9716669548188311704969626601027296830809246015644883490860409903708929680E+7946962', 78, 3);
t('9.9766657347831312895713804962380972879872133625410810249905126198373397e+4902005181527', '9.9533859183595836960393341304494815647224E+9804010363055', 71, 2);
t('1.55e+26246', '2.401659339220326238148181906366427704224780832955898700E+52492', 4, 6);
t('2.34305570615805937922628235012415265e-7', '5.4899100421598422967909002186123690839377971716E-14', 37, 0);
t('9.486832980505137995996680633298155601159e+996590685', '9E+1993181371', 40, 0);
t('2.2472831e+47363932428322', '5.05028103859772651487706403994190016339078351595454246848636742496802495048742202447079630739E+94727864856644', 8, 0);
t('3.09835648876358033e+47479603614', '9.59981293146338228219992128891802378333E+94959207228', 18, 5);
t('8.55135371363729866747197e+16028', '7.3125650335738419022159017437377735662828E+32057', 24, 3);
t('7.541423725038898641083750859464767137139684e+12', '56873071800579577894480029.9913916338494896187006254131382792065617290802105695797397', 43, 5);
t('6.8002746166354257e+11', '462437348616560861444716.469443110926995223677083942242611169677743650813236751337419207369559128520', 17, 4);
t('2.5652177e-244584256384357', '6.5803421671668747304683336293E-489168512768714', 8, 3);
t('2.23793617809742898841363911292888853966977964817766258759532718005259729e+41087371', '5.00835833723732739992314400670207943302403206440405252937804763314822035527687053E+82174742', 72, 3);
t('5.23407164867045527149076121386206081046e-3542587', '2.739550602341585775997338219789670446820E-7085173', 39, 0);
t('3.0742131314253906754227821858e+96706326503', '9.450786377428306361560309171177304320240134953027243301587893245054872736802088043071493639E+193412653006', 29, 1);
t('9.6526054e+6', '93172790036170.613444694347666418780549753491881062334620953897827553473780799108203', 8, 0);
t('2.764550263766756063892234262466594517907118311533593420860995828119465404401809e-431912159', '7.6427381608928405257681569294347818369102356176996211973E-863824318', 79, 3);
t('4.726185048245726940640138085401458332003103e-2387', '2.2336825110261464289548790065115800838432265E-4773', 44, 0);
t('2.06700039e+27664', '4.2724906128719667659691356003183719988200264E+55328', 10, 4);
t('3.0394538316874649464598276081160724e+106145874', '9.23827959495961249186367387478693953484941E+212291748', 37, 4);
t('3.006875499403192963673188892347469682563777463469587792654e+20786', '9.041300268911201088838782013152679784074371858101273E+41572', 58, 1);
t('2.85909217357538160219868784409618103905259254542127e-30883978641744', '8.174408057E-61767957283488', 51, 1);
t('3.3260210094135369128622169846679339403575787017793503761274203309290260436e+3815171969334', '1.10624157550602430015244848049439711918773950918589248425841376113701453944821290918195E+7630343938669', 74, 3);
t('2.2219659043755149394630379e+39005143', '4.9371324802073E+78010286', 26, 5);
t('9.5438933355313647910084093295703513e+363658650', '9.10859E+727317301', 35, 3);
t('3.00666e+472622870', '9.04E+945245740', 7, 2);
t('2.837780823108084927845098354231270362354547981102e+3799336425332871', '8.053E+7598672850665742', 49, 6);
t('2.63098328861837901379246055794913493258563428302007e+18474', '6.922073064989180646258163061425595248339645318548644890836321470068254933488292945284735322631E+36948', 51, 6);
t('2.764594001353016120387309e+1656763472', '7.64297999231708049848271603772247952906531812E+3313526944', 25, 0);
t('4.99358959259322115994443893492663456542067e+21163752', '2.49359370192553324844573464720642409E+42327505', 42, 3);
t('2.027895093136415935e-33', '4.11235850876675305992625132144861230486080916955691E-66', 19, 3);
t('2.9545024474453888695924718967207697287659510106764672439630841479565241968e+3025138', '8.729084711960792819353415468437350816065576927664405E+6050276', 74, 5);
t('5.274723829579e+147', '2.782271147832686219E+295', 13, 4);
t('2.8438354740227241040111232893777368e+5046190127387', '8.08740020331005190220391258674305873512363906032235E+10092380254774', 35, 4);
t('4.7022502775686244544842e+785', '2.21111576728942057265374867434598092629448251165002373458069847941389903130518761599813923261736272E+1571', 23, 0);
t('1.9179842370578362891185422e+3826111', '3.6786635336023303507152224116804583704219412283495446611E+7652222', 26, 3);
t('1.294105809149064963260379265e+33012', '1.6747098452733561507694771361540079238390082400869150000987128223006851969007181E+66024', 28, 6);
t('2.6259981818539021981659e+339340', '6.8958664511E+678680', 23, 2);
t('1.650095715573914339995571593605530228843869509809576660267100705710199e+460348481858', '2.72281587055538841173686928082096620997022877836901707243689996E+920696963716', 71, 1);
t('2.5961509971494339104070358328276508155305955410565531e+27506184764', '6.7400E+55012369528', 53, 0);
t('6.98318893856197088096157423785895630275546e+1', '4876.49277516542655231337713128136167574490306845440883621473529483335813066', 42, 6);
t('9.0231652121710693691311381001357983609378069176681239052663552490593273e+472', '8.1417510446134179304795008671281142077622655031292884E+945', 71, 0);
t('3.614556567833e+905', '1.30650191820664E+1811', 13, 3);
t('9.1398161452037739597682402466114e+2', '835362.39168127574079882209155115811445457403061495355495204551760538374', 32, 6);
t('1.48195910345e+265', '2.1962027843207439856796146949959914521607703076789660614150E+530', 12, 3);
t('1.5556e+14554', '2.419900615649606588649129133146016064773740775801480E+29108', 6, 6);
t('9.577563741597269956621661494375676941761541216043791043763111011243284670677e+148495594025', '9.1729727224358697241613267368499559222661984280657781520944350143634252209378072E+296991188051', 76, 0);
t('1.8506236700427283766082924116700167702e+869890601624', '3.424807968122417190265786224803414598744313823843255233059744E+1739781203248', 38, 3);
t('9.826305933387008239476331241821733277265221856e+322094481799', '9.655628829651672320852209236659488021285268281974300650419875326E+644188963599', 46, 6);
t('2.624529228150198019388839742009995469e+207078651009687', '6.88815366941467416777000064485475542793749913477244591699232199964730E+414157302019374', 37, 0);
t('1.6072e+444880748', '2.5829424561385859658292788297683281827868597224516601440089262848450E+889761496', 5, 5);
t('4.14372056656893949780344576110128553784727806963084424e+35972549165834', '1.71704201338064129520393922040426764484532952194442522349724910206873998394075971283951735644E+71945098331669', 54, 2);
t('5.0531262501544526519574040306536300193230181695512694054594791474960429e+43540097', '2.553408490E+87080195', 71, 1);
t('7.82604e+4', '6124701461.30253396696741160592218892208', 6, 3);
t('2.2398583586237716716486413363400318012837209715720882626185e+47', '5.0169654666967765488407729714423591421E+94', 59, 6);
t('9.880231068423594927351688244474459194937005e+644353', '9.7618965965442852147114138973091944182243234357713569889829E+1288707', 43, 0);
t('4.962894523835293602541700098665678245210425304527057712473799410572054423102e+99', '2.463032205471434562E+199', 76, 1);
t('3.079618529786431417491547e+33473302', '9.48405028900394137180787430531224638858239194922517032274376483841159408163465435135E+66946604', 25, 2);
t('2.55106412528206453900085028710092456169084330858943744594958242411029891729e-36', '6.507928171301145077839025428E-72', 75, 3);
t('1.599636494099434519120495776736793381468862256137471e+4144316766399', '2.558836913254730207106858879274826091287738890342230033749159837590085448680594119987E+8288633532798', 52, 0);
t('2.07272418e-12884693243', '4.2961855225494E-25769386486', 9, 6);
t('8.69228216461714213735790110145447192421003957520348071e-1861021855949449', '7.5555769229321270082798708075E-3722043711898897', 54, 2);
t('8.24962547017544740347522820382134272105255583449e+2865', '6.805632039816747163674E+5731', 48, 2);
t('7.27483292499446870635760964657613202175753147622053e-148221990584', '5.292319408658357715078502155762867585E-296443981167', 51, 5);
t('4.90795797150709105376962677572069305380908614111297365553e+4086', '2.4088051450080E+8173', 57, 1);
t('7.34786550466656744803006128046e+2795776346528318', '5.399112747466886993138311223824932339056153376414279E+5591552693056637', 30, 3);
t('9.70637064951188141912617586468613169489040932e+9263851', '9.4213631185705702766011583868449956283599883063266590478542230153211906005516607505881153E+18527703', 45, 4);
t('3.14106344730876479475193343625504e-910', '9.8662795800192214301268467968737763973E-1820', 33, 2);
t('6.8863641511930920159e+1434', '4.742201122283735467286752580639151338402147978758E+2869', 20, 5);
t('9.1536625949357836061871605822069283444244503528403697e+93673802', '8.3789538901926503620943368526446290753065226079800268864837819950868226858046E+187347605', 53, 5);
t('2.050219946066689694568885168e+41880885', '4.2034018272497E+83761770', 28, 5);
t('2.58797367988247572680336566731031833e+3461935', '6.69760776776444294842577371961987758394584550633726992061849437263890087941E+6923870', 36, 0);
t('6.0585255787e-340010557', '3.670573218788407507689514263121673716122995116133303311009468985401267408779E-680021113', 11, 6);
t('2.033581e+3480', '4.135448217987841390586067157756058403489565598382242753255526546540540095751E+6960', 7, 2);
t('2.4573907806034206508145897417338517767341675713702823338890812489722423677833e+38617943', '6.038769448594689087910861123468200183610626181299843431865263126830407743069E+77235886', 77, 5);
t('1.8941557084570725928674400770347757019608538011645519465e+304618795294', '3.587825847880514585709358773677324854320097535772497696497628452E+609237590588', 56, 3);
t('2.32812250747228299412e+313837', '5.4201544097990303858141E+627674', 21, 5);
t('8.60645693084276008079123831702972740385e+154', '7.40711009024513815760164703475393233970877193508242149988958928091491914E+309', 39, 4);
t('2.2706488927283296329062209956647601583635908763632678803367026671603381e+37', '515584639404838941246901894159595954745567752911318738407100564309750626516.1791617', 71, 1);
t('3.39893741999727121585845223399480273146968e-1897475', '1.1552775585057706466940388889077953341599272409994467228416821444233007E-3794949', 43, 4);
t('5.5136e+166880406', '3.04E+333760813', 5, 5);
t('3.030059156073167836053285715808361515527841237119577e-4844973118878', '9.181258489302838079121284106371E-9689946237756', 52, 3);
t('3.01621123e+412557134', '9.097530205431698341141736543467287960383290070775938518339807290620844422120352E+825114268', 9, 1);
t('2.7692987e+14174', '7.66901510445223617671270401903922314736658973717857677577742198978502434481269112716631157122727993E+28348', 8, 2);
t('8.1163781879836183909409375363404068136137574908934e+204971512154', '6.58755948903762446750976327895628343674985502155875440613151906714494399548343042750830709062E+409943024309', 50, 2);
t('2.2572378462909762847780411032884150727038656700793e+46981', '5.0951226947283250806636033744756427856016086366224E+93962', 50, 2);
t('9.0281062255204740105304768996726311145672013275416789795275497995048942097e+226702402736093', '8.150670201928153993411272129594404183375704672E+453404805472187', 74, 3);
t('2.64772769892363307093059365640630051052232478304226906666646516317583776e+295003889110756', '7.0104619676474369342365609690167930592871571199219650021680E+590007778221512', 72, 2);
t('3.13423173774023388222090399070014419184070085892e+2', '98234.08585858166222466900865352520714306', 48, 4);
t('7.5875e-145', '5.7570159774745196978712550411544E-289', 6, 4);
t('9.019814533002418483218041677971520150196e+3587590862646067', '8.13570542097616366291558237185955227709177843801016027464366840371504045382881466535960323E+7175181725292135', 40, 5);
t('1.35383017303503354367849439544524371635138052709984972e-317514', '1.8328561374200688659993455967130023996868394E-635028', 54, 6);
t('9.37621997569568303472309542853412757889934365090285260995e+2197', '8.791350103263475495836258678650727954866E+4395', 57, 3);
t('3.0504548177905637298e-12020179286', '9.30527459538166136476938267777527342524470683073510498487415309409144843033563741336552377142559E-24040358572', 20, 5);
t('3.086354295687660799750652512900547113767349372521616998883899383188989461278e-12', '9.5255828385096767511E-24', 76, 4);
t('6.01199e+2879412', '3.61440703564099768E+5758825', 6, 1);
t('6.4466262346647814710667613602892424745155045175684165271079e+3092341', '4.1558989809468218098954125905590E+6184683', 59, 3);
t('2.33792157009946435002902338510510938904819610116259987000091846057423155518e+1006816', '5.46587726793634459876766095307E+2013632', 75, 6);
t('7.52637894342292600459229452291474918313e+41', '5.66463800E+83', 39, 5);
t('2.5626769096419963476340903043996166294265167882558946536e-526', '6.56731294321225271290059931898686901695490329384659866588358271112311008476E-1052', 56, 5);
t('1.97484176581314990174384610437230990660852618680820080988126186147286133697613e+39070', '3.90E+78140', 78, 5);
t('1.45440475274653711374621434742103752e+477036835198', '2.115293184811715756111035E+954073670396', 36, 5);
t('6.1992027227922108538280901695224715931051043157545802926356061644672662141e-4', '3.843011439827436064752567943485332632909203518838336622636143406313606434503297E-7', 74, 0);
t('1.861442505620019066170426433408338273749989194997433001e+25044421131632', '3.46496820172893471274450231665851340050925461712723830282019910966406769659794792E+50088842263264', 55, 2);
t('2.96906281918975236955954438611698479173299363074681248825253049431984948e+2137858258433490', '8.815334024295000171588787248553700566011567E+4275716516866980', 72, 3);
t('5.175035338263985141e-19506965', '2.678099075228103912053736336553650966855863923E-39013929', 19, 1);
t('5.6856749819172745252775650565521e+444143632171956', '3.23269E+888287264343913', 32, 4);
t('7.8957265213531807075664078327696484000996048294363154908871e+11785538569', '6.234249730E+23571077139', 59, 0);
t('1.8283610369653862758941525973088006356e-393', '3.3429040814931426E-786', 38, 2);
t('6.324555320336758664e+2759', '4E+5519', 21, 5);
t('2.622555500020207157785460692451466974946442382680558e-42303129343', '6.8777973506862387855796638472705729011046488677364623807540946604353320E-84606258686', 52, 3);
t('1.9200171460327483539026314778967671885846184667896514124254004538864392e+46889086360', '3.6864658410597401179937293588455580384542595E+93778172720', 71, 5);
t('1.32991783013086940115047303330105611393593893453e+2137996', '1.7686814349E+4275992', 48, 5);
t('8.504876072821706451854804787270754918424940970464942356230569216208409282293e+1954155074', '7.23329170140551722658511E+3908310149', 76, 0);
t('8.989429645304548256737997439398050197279956353931606298464860617251463e-2145138768798', '8.080984534788025628E-4290277537595', 70, 5);
t('2e+87988', '4.168731982E+175976', 2, 5);
t('5.2064477870639497e-28517', '2.71070985594230989175938821603202E-57033', 17, 1);
t('7.2266787484135478395239424677393393e+34292647220436', '5.222488573277200227050900075314803902522307294599971E+68585294440873', 35, 5);
t('2.65893085873818746784799462956040824680806779629363141352213215464903828502e+41', '7.06991331155019503904475228560073103E+82', 75, 2);
t('8.881482619e+2095399787486186', '7.888073352767506531631057273649734668539553289948510498240822582019489548040318306E+4190799574972373', 10, 1);
t('9.80332759539657e+1', '9610.523194266382981096232960460004238837580104560636452314738102557965139756002214949', 15, 4);
t('9.082984330509808229878255253074802885120895971e+4349613472438', '8.2500604348286709226838364974088837798915132923152211474564761463852274150514234984081825E+8699226944877', 46, 0);
t('2.3051841717555917375661e-3805332', '5.3138740657125134679225950980E-7610664', 23, 5);
t('1.58649846866898977e+17', '25169773910890495218058815869093616.163248025716892103133483661936354157144385347', 18, 6);
t('1.832487619892217619778605787594363341371e+489189', '3.35801087705824464519194153474023E+978378', 41, 6);
t('8.46288196383477866594835930945604975e+68975897', '7.16203711338E+137951795', 37, 0);
t('2.15903826476511767107e-426122', '4.661446228719970353170383319438925741090187385001608608366288E-852244', 21, 5);
t('3.25286507801e+13148279697', '1.05811312157440264046383518534621E+26296559395', 12, 3);
t('3.926939618857446e+2701650423077205', '1.542085477015226E+5403300846154411', 16, 4);
t('2.300649433664730442433670197221423917e+33169', '5.292987816621844920407591519790997148291859608855681470609202096937600310235150613372875022280048179E+66338', 37, 5);
t('8.587979082919625568762e+0', '73.753384728665013020438300', 22, 4);
t('2.068686747170362320265134050006653074465e+34', '4.2794648579182945572703279910205170577550420354118714938358645443205E+68', 40, 4);
t('7.69e-46140374415', '5.9182163506875549546680576005992720902216355454971484890245944725555E-92280748829', 3, 5);
t('1.8175779968958926637429567383064725023e+489880727845850', '3.303589774800085601596674E+979761455691700', 38, 2);
t('8.919264136401625271884219060858252e+9', '79553272734900230263.41763128677730026531493235388640071381802652591', 34, 1);
t('2.684345427e+44565', '7.205710371469E+89130', 12, 4);
t('2.9534086394e+225110078', '8.722622591246883914133438987850898330671972588389730184309208739334634887878346367329202E+450220156', 11, 4);
t('2.2293525e-29', '4.970012461272812033092318803761409304947044073671573877964943E-58', 8, 0);
t('2.12326974896414051580077536570530341003518e+129130', '4.5082744268662442849713715921E+258260', 42, 3);
t('2.5833750802158470838638220584e+18913396', '6.6738268050802343551355260020766554923882450343012342734378848E+37826792', 30, 1);
t('1.0482628915520200483e+1', '109.8855089805002144728403440947030093340246871753530', 20, 5);
t('1.49777148251106029879789692329117828615e-494834655520847', '2.24331941382337940650496041556953252175484515884385876892851088684239094331708000189663420216840E-989669311041694', 39, 5);
t('6.95456711664340560996070853420178762114841e-38627491422785', '4.8366003779897772450979302026969538397871395603455798715295598491356099722574E-77254982845569', 42, 3);
t('3.10149148573625247e-4', '9.6192494360944667705321067387464882437575358E-8', 18, 5);
t('1.9575110120741046328968e+257921497', '3.83184936239138541387679462617387283711241414931326900113204911095477961E+515842994', 23, 0);
t('7.7671e+1441473951', '6.0327727774912176230101E+2882947903', 5, 6);
t('1.55009951392721507762173021041426457646284757348955667596e+4760', '2.40280850307738845039513019493014927568794808938729593338641386181207198737391954656000091310896E+9520', 57, 3);
t('6.97734691743388618569498e-29', '4.8683370006224153769363821987754694567429898400322317885097538299174433336292355572118157532513893E-57', 24, 4);
t('1.4993331851193049612203995625656077760057082447306644612348e+2339610533576283', '2.2480E+4679221067152566', 59, 3);
t('6.04693544698469e-220', '3.65654283E-439', 15, 1);
t('4.92955e+230982431475', '2.4300466966592452130220374934414E+461964862951', 7, 6);
t('3.0764244910060828198383307889390376085e+4181965985826', '9.46438764886203575285E+8363931971652', 38, 0);
t('7.4513572904573959e+293', '5.5522725470052584411450816E+587', 17, 0);
t('1.245345961467927340281476373719978090064081519e+42', '1.550886563744476367740974406041099100674095756961953547612335899E+84', 46, 1);
t('1.5499077392523e-4', '2.40221400019421603693694579636622069903401E-8', 14, 5);
t('3.07185786e+12919', '9.43631065159385809410362801786965384978640704874013E+25838', 9, 0);
t('2.361286043755e+281976835', '5.5756717804303509418805557E+563953670', 13, 5);
t('5.47722557505166113456969782800802e+405615457129', '3E+811230914259', 33, 6);
t('1.7178698335153e+144561611584745', '2.9510767649015787272590443004662758146251322168953340785510127474489250982992775086288323854164153E+289123223169490', 14, 2);
t('2.2011e+12378959348', '4.84515086803287598716648233379771635161708841282201798840424143306973602425697887937893645861532E+24757918696', 5, 3);
t('3.071695622941830478526650605376658041302645824732e+28109511538117', '9.435314E+56219023076234', 49, 2);
t('2.307714697590689989764e+284', '5.325547125476089750844425629104815411440491176993481E+568', 22, 0);
t('2.5862546754279728496914821072086e-33773833', '6.6887132461730491917584965749675495749719281864675587283858319408183402627833958E-67547666', 32, 3);
t('5.74069223118780469804395537303763292412320069e-28', '3.295554729322001530304774161762307365140729343455866587659018918667945699638475469150683153123653323E-55', 45, 5);
t('2.53435553329728248339409747785119424231260889160560714e+25943171346', '6.422957969154553102396E+51886342692', 54, 2);
t('1.4069894208184455429860946489038258613329117231491e+114452', '1.979619230295024840325033863086398472578753367030579325792446632992E+228904', 50, 0);
t('1.118294004710828525178841841394721727540545598338176097e+1', '125.058148097218257166460091', 55, 4);
t('5.888425440747775688e+2065204358486413', '3.467355417124563636358862403139990401147625419807197821070468E+4130408716972827', 19, 0);
t('3.0558360616281147776649165585589148e+202', '9.3381340355468272974654269623217477382915449047483811417E+404', 35, 4);
t('8.49192304e+1387453895', '7.2112757E+2774907791', 9, 4);
t('1.6985163959801521e+3936837', '2.88495794741340509204059372399499124467343954532861012543791870383E+7873674', 17, 3);
t('4.991092064869170494e-124451984', '2.4911E-248903967', 19, 0);
t('5.9823664195735900053440901869404771842353600892916293363151e+2227900957', '3.57887079780417347338180368431509195268242653234667944437089019357950841991042084010E+4455801915', 59, 0);
t('1.90934970073455410278410575623977888122382805484e+422554664715', '3.6456162796951313121087727108063524737724086412612828706606881122179782708607529986314383405E+845109329430', 48, 1);
t('2.599310207388995318083e+398467', '6.75641355423662185068716628560209294936028E+796934', 22, 6);
t('3.7633102634136297417364966e+778600439757179', '1.416250413871436327348908304665878915237348394E+1557200879514359', 26, 0);
t('1.2047068181e+31361471610', '1.45131851760962261131924534974E+62722943220', 11, 4);
t('4.35951628054340993989341222113828625466454197009e-21152924900022', '1.90053822003230473596535984483816E-42305849800043', 48, 6);
t('1.576844611205999099662237540201844126209316481620105534e+335357340260426', '2.486438927889398461388938E+670714680520852', 55, 1);
t('3e-414034', '6.47961009652494321346331325444614339994562352820030434758628977937286889619097368135E-828068', 1, 2);
t('2.7450159803706115172884307982554068123557452994357916574e+29493402848956', '7.535112732490029474794930517417328483099871453263111571224994801873955541077813E+58986805697912', 56, 1);
t('8.450708163926728117884231904577733365414280601e-3356220959', '7.1414468471857852311230634694477427663911004991250862311231174531532437446075636178902521E-6712441917', 46, 2);
t('2.21717604626595076e+2233028', '4.91586962013551338731303957E+4466056', 18, 2);
T.stop();
})();

125
test/modules/tan.js Normal file
View File

@ -0,0 +1,125 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('tan');
function t(n, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.tan(n).valueOf());
T.assertEqual(expected, new Decimal(n).tan().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 40, 4, 'NaN');
t('0', 20, 4, '0');
t('-0', 20, 4, '-0');
t('Infinity', 40, 4, 'NaN');
t('-Infinity', 40, 4, 'NaN');
t('3', 5, 5, '-0.14255');
t('0.8', 7, 6, '1.029639');
t('539998661123466984649191689138494900416386817996524', 7, 6, '32.04695');
t('0.5172293543584894071801901902', 5, 1, '0.56888');
t('5', 10, 5, '-3.380515006');
t('0.5283979979897015', 1, 4, '0.6');
t('0.032294', 4, 5, '0.03231');
t('6339441327243052114957865586706124503.386166832963015135918043343179', 7, 0, '-0.06666567');
t('0.9483926380646355642560348839879277', 4, 6, '1.394');
t('0.4989999', 7, 6, '0.5450046');
t('80', 8, 6, '9.0036549');
t('9', 2, 0, '-0.46');
t('710.0571640039', 2, 2, '0.058');
t('2485', 2, 0, '0.00022');
t('1', 8, 1, '1.5574077');
t('1683930704126586032365374681825182443446390958574678366195884605194996193', 6, 1, '-0.540063');
t('4', 7, 2, '1.157822');
t('488888888888999.88888888406189896488888888888', 9, 0, '5.10971582');
t('0.76322415', 7, 0, '0.9566071');
t('0.005', 4, 2, '0.005001');
t('0.313', 9, 6, '0.323638526');
t('9798000000100000070000000000010007300', 5, 0, '1.1308');
t('0.0000002', 2, 0, '0.00000021');
t('7.9548', 4, 1, '-9.885');
t('7', 5, 1, '0.87144');
t('50080000', 10, 3, '0.3252122977');
t('1687619439340503284670339680.931590414877', 6, 6, '-4.69126');
t('60970535.5', 3, 1, '0.804');
t('0.17', 3, 2, '0.172');
t('0.5', 5, 6, '0.5463');
t('976.8', 2, 0, '-0.24');
t('5957.69', 6, 0, '2.82277');
t('3859393443331162786655368.87986161531415848272022672234461227844', 3, 6, '0.47');
t('0.5', 1, 5, '0.5');
t('468455006548968895675682202443647176252098177665257898933', 5, 5, '-1.4111');
t('26588816756666', 1, 2, '0.07');
t('0.239424045403994683949187909216', 5, 2, '0.24411');
t('810209.109', 6, 6, '-4.52238');
t('799063368.11558288974072', 1, 2, '-0.9');
t('72.3640503', 7, 2, '0.1078344');
t('843003462755848631687717888604', 5, 5, '-1.1699');
t('90706.61', 3, 2, '-0.676');
t('0.1', 7, 5, '0.1003347');
t('29555.88888888888885555555', 9, 5, '-0.218161582');
t('3079999999999999999999.999949999999999999999999999999999999999999999', 2, 5, '1.6');
t('6', 3, 4, '-0.291');
t('9.648589238187519', 7, 0, '0.2276248');
t('590.89', 7, 1, '0.2773838');
t('807876335', 9, 2, '0.965588602');
t('32099561.989', 8, 4, '-0.24584079');
t('7743398777777777777777733.77', 3, 2, '-0.526');
t('45.52', 5, 2, '30.207');
t('399999999999999999999999999999999999999999999999909999999999.99999999999999', 4, 4, '1.742');
t('32400', 3, 2, '0.941');
t('4152914444444444444444444544444444444444444444444444444.944444444440444442444494444444444', 9, 0, '-0.101470716');
t('90000000000508319.117628510842726222', 5, 0, '5.1435');
t('0.0074072', 8, 3, '0.0074073354');
t('0.413272', 4, 5, '0.4385');
t('0.8633', 10, 3, '1.169338115');
t('33333333333333333333333333333.33333333333333333333', 8, 2, '0.5813679');
t('562', 10, 0, '-0.3594685138');
t('6433373233.39333336638333334', 5, 4, '-1.383');
t('233333333331549444444444.09076555555555555', 10, 4, '-5.305366526');
t('40', 9, 2, '-1.11721493');
t('906287052558597992196230844623', 10, 1, '0.3528425701');
t('900000', 4, 6, '-0.3334');
t('57777777777.88888888887777777428970596211366', 13, 1, '4.620958871418');
t('33109173612614237', 15, 1, '0.697054002938309');
t('446571', 8, 4, '-0.11299979');
t('55.33', 25, 1, '-2.721513818553435443556001');
t('0.6874', 3, 4, '0.821');
t('97415551555.55555655655655554555555855555', 38, 6, '0.63497857004739965579501336949790595112');
t('3052744161971196989887333333333333333', 15, 0, '2.3893665412711');
t('20083.4596122', 37, 0, '-0.9171727446291034528773430723329592848');
t('9200', 30, 3, '6.43843719089952501300840146253');
t('1', 23, 0, '1.557407724654902230507');
t('78887888588.8', 15, 5, '-0.0613791279629461');
t('1147231', 8, 4, '-0.097582634');
t('0.000553763344', 27, 4, '0.000553763400604559119913346525');
t('68', 24, 1, '-2.04008159801594615389349');
t('49999999999999999999999999999999999999999999999999999999.399999999999999999992702', 15, 2, '-4.12257063808152');
t('49999999999999999999999999999999999999999999999999999.99999999999999999999999999999', 38, 6, '-0.41507238166911582158673379470559517419');
t('0.00000391163258651029507727', 31, 2, '0.000003911632586530245537172208314767');
t('0.17183171313', 36, 4, '0.173543103883274147884533120728007237');
t('861646.5732966967557082', 34, 2, '-2.464947656728891301675656852697406');
t('47777777777777777.410171', 105, 5, '-13.74058038972407219477409398839850580956304359987902889186211451339313466403485175336849944968942741891');
t('0.390071731702448005162815294909486174474947036240529240590971978418532990165699316733956931596883519677657915509998387416505531185920438999174869181240110048120035540672577', 63, 1, '0.411138769556421473902517663320961167226706740351370710111315144');
t('23174769554', 70, 3, '0.2212756420749658903960662285747816321880538429001022336777294070264195');
t('0.5592', 74, 1, '0.625835640923790139625307834841776614566589496394316390500913130105766275');
t('6661489439437775791.114329793186996632507954406585491', 17, 5, '-1.5847845023422794');
t('4391137181720764819571909798888888888888888888', 86, 1, '-0.8685635418477878118403689813703497084174127945629019783498553011616589497613259649227');
t('300000000000000000000000000000000000000000000000000000000000000000000000000200000000400300000000000000000000000000000.0000000000000000000000000000000000000000000000000003', 122, 3, '-1.5903229154055637520787252214804110216069360069379104488574199058901135519171083962076619886567087892277814852998414939069');
t('6587685840713754402278094276205491723366077405819490595067025408026873250375623638673063957701601231', 107, 3, '0.88106648906135934944047838538886082156746682725824571546159607795133625640190620741982638843180493222615294');
t('0.524217411165998018391262237830297491516856805040463896080592290487405064611025001607311512479709354535407130581948832593516281243820812174844723190311545869854968531247730387537943969800839367585396013641826800875467649274673709974876292276089324234102809573076731030535244688816', 76, 3, '0.5781754114340578960371795632804762026798421163023137415437904934165060267084');
t('323646192595.4845', 127, 6, '-0.3747612268270038347175054875779625030989108207803221587812055629899198693615407534041949990189331417585285760850333254670480789');
T.stop();
})();

126
test/modules/tanh.js Normal file
View File

@ -0,0 +1,126 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('tanh');
function t(n, pr, rm, expected) {
Decimal.precision = pr;
Decimal.rounding = rm;
T.assertEqual(expected, Decimal.tanh(n).valueOf());
T.assertEqual(expected, new Decimal(n).tanh().valueOf());
}
Decimal.config({
precision: 40,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', 40, 4, 'NaN');
t('0', 20, 4, '0');
t('-0', 20, 4, '-0');
t('Infinity', 40, 4, '1');
t('-Infinity', 40, 4, '-1');
t('0.20269', 1, 0, '0.2');
t('0.42', 6, 5, '0.39693');
t('-0.35339119', 8, 1, '-0.33937958');
t('0.153', 8, 1, '0.15181721');
t('0.26', 1, 1, '0.2');
t('-0.5', 4, 4, '-0.4621');
t('0.5301167511', 10, 0, '0.4854703307');
t('0.1', 6, 2, '0.099668');
t('-0.1947', 8, 6, '-0.19227651');
t('0.62055680437965736490569245685566214324448351639', 9, 3, '0.551515589');
t('0.8653929782497126681556355800799811365862905422680464', 2, 5, '0.7');
t('-0.223453445837184', 10, 6, '-0.2198071371');
t('0.6228344', 3, 6, '0.553');
t('0.3860621505234646348994570686682533147396620957827359578508068456', 2, 1, '0.36');
t('0.5499', 3, 2, '0.501');
t('0.27', 4, 0, '0.2637');
t('-0.20874419', 6, 0, '-0.205765');
t('-0.9', 9, 0, '-0.716297871');
t('-0.66', 10, 0, '-0.5783634131');
t('0.5', 8, 1, '0.46211715');
t('-0.8730255767917122199088529', 5, 1, '-0.7029');
t('-0.3', 6, 4, '-0.291313');
t('0.0772947', 5, 6, '0.077141');
t('-0.1', 5, 4, '-0.099668');
t('-0.5530719666927749554276959', 5, 2, '-0.50281');
t('-0.76695591420216557012230781', 7, 0, '-0.6451559');
t('-0.28931973768077305489831982152049', 1, 3, '-0.3');
t('-0.631664433177866683720536966087102', 3, 5, '-0.559');
t('0.4647093', 9, 2, '0.433914635');
t('-0.293097', 2, 0, '-0.29');
t('0.39968', 6, 2, '0.379676');
t('-0.56478323116711527', 10, 5, '-0.5115177648');
t('-0.60158', 2, 2, '-0.53');
t('-0.566', 5, 6, '-0.51242');
t('-0.5455', 1, 1, '-0.4');
t('0.181743184255049315571704802510832099', 6, 5, '0.179768');
t('-0.7', 2, 3, '-0.61');
t('-0.410626', 8, 6, '-0.38900408');
t('0.32', 10, 1, '0.3095069212');
t('0.478', 9, 0, '0.444640449');
t('-0.2127882653536975970432160655692', 1, 0, '-0.3');
t('0.668', 9, 2, '0.583662747');
t('0.1054319768894549379656717', 6, 5, '0.105043');
t('-0.2159146041935965', 6, 3, '-0.212621');
t('-0.53', 5, 6, '-0.48538');
t('0.35', 10, 1, '0.3363755443');
t('0.3', 3, 2, '0.292');
t('0.38276035385122733156525463', 1, 1, '0.3');
t('-0.751550287803356896438162105272645', 31, 0, '-0.6360729215504306567971084126656');
t('0.2958626290477698111067628542902641468424491987425491552317600599757584700042', 33, 4, '0.287521804057197325874867763687105');
t('-0.1624241525', 60, 5, '-0.161010729348804314083016365256060397030839070169914629959771');
t('-0.3246133', 23, 0, '-0.3136723151870226491541');
t('0.7574510519751273', 52, 2, '0.6395731248592590736391239000170979980280431536354096');
t('0.52677087', 9, 5, '0.482908861');
t('0.01504298596871499648833185964254026', 19, 0, '0.01504185137182836531');
t('-0.66543541401805503420777', 66, 4, '-0.581969286944420744706095110187298812957954793212156080645254407938');
t('0.016497376645717697522865', 24, 0, '0.0164958801477289569077129');
t('0.79228702880353249365', 45, 0, '0.659702681921377249169326566285194050648896939');
t('-0.32047744', 35, 3, '-0.30993856125352144923141124282332793');
t('0.78607526651121', 28, 5, '0.6561799353543745431928429623');
t('-0.130782154855323731897567604029773075178369276247566438028657144457559876456195235141546572', 80, 3, '-0.13004158964612601126893011628900193563954656630020761998126577892190799298653838');
t('0.543888568', 52, 5, '0.495925821522156920755419346170717806152690266078471');
t('0.595946834719509046130665028731095130596', 61, 0, '0.5341591488247401589317435849855958281981025417248174269032896');
t('0.8180710003422039739052425209159024776836992576782', 75, 5, '0.674018589934549659108491437885993668870523407722879795457767225797625110655');
t('0.2002343534718092035', 32, 2, '0.19760053356302078332195382537244');
t('0.4316', 73, 2, '0.4066575843743152347702788188048559212155195983052915894345749387848887185');
t('0.0297026', 47, 0, '0.029693868096821512437865399347977108636469769826');
t('0.53196297398345769364909690685747648864854530119854', 56, 1, '0.48688016788770163925717272861291678368256194265983517854');
t('-0.86540495196', 57, 4, '-0.699031973057205236065847483268440159156292260431585544883');
t('-0.0218982341955013979387277630591838547', 66, 6, '-0.021894734560604770532346703409220449766736745588134181835811694617');
t('-0.3503134189235148094342514029278811316170849354159958798993', 78, 4, '-0.336653471066707838641123262575513511831303224617968974634023553683297404695416');
t('-0.666924383326373492780403568920198080574', 25, 5, '-0.5829531066013566651422653');
t('-0.44325150067844726483860902210607088446679462', 1, 1, '-0.4');
t('0.9034751706768019789827', 60, 6, '0.717985782691067206453512080792613565326893708313975428005223');
t('0.2172485076904694895179', 63, 4, '0.213894002682974109904624836689545795117673726509639521578182275');
t('-0.348534855137810830366231027941', 31, 3, '-0.3350755386644384737516713339319');
t('-0.4255195', 45, 5, '-0.401570102011929569917989543792334637564089692');
t('-0.886162172614361731', 29, 2, '-0.70949297599079569125232530876');
t('-0.7', 78, 5, '-0.604367777117163496308687183103826475015566647416860888612419993599538639474122');
t('0.757119675718', 66, 2, '0.639377257808623037769808128229970838858747391194193471609343942998');
t('0.2642178764761', 55, 6, '0.2582364046844679768754362197481015404352489557723913895');
t('0.321329', 74, 6, '0.31070811547650274839857700104600776395241041487409731293147237247772091748');
t('0.1682695184810800667294209270614384694422368505868903621013683783929', 16, 0, '0.1666991388738522');
t('-0.409858192536257152668045191854122303323410295894', 43, 0, '-0.3883522664291927890893297914389310714602415');
t('0.2880615', 120, 0, '0.280349643265659497705660848534086455056558585660980017680059937512840019825269028854239781634733893540906928184561638591');
t('-0.2803292668048951604355466058306354327579221441238441133669431820221412822995', 69, 4, '-0.2732097971115351269678804248529217531253775527585485646027761857336');
t('0.209183180524407073852661413214033433796240391516313838917745903006946400344329579472178537414263299679577464721107342550013722994343049', 3, 0, '0.207');
t('-0.21323411415637447', 100, 3, '-0.2100599987497949082863636944922996664334987508835646248560687414181626030840090573861293885022227807');
t('-0.934150529137316227495052114810154290011321681684010680698706327964978851230256', 97, 1, '-0.7325231466730630602965757839383259193306031234060675020081884134754348821771511575580397417734494');
t('0.612797', 135, 6, '0.546092981987055113177270374342598658047265622605927205095448291249934086020550572905344645120234563581014732729130051050396440278747926');
t('-0.18273791076980028567544728336113017263732539776346366568034574', 45, 2, '-0.180730653506873097396527854034699651896910694');
t('0.5288356309407208928920467515068426806', 107, 2, '0.48449053794065651739672070077375035256792292259097100512145231251249909428817259447380109781326377031262135');
t('-0.50752591', 24, 5, '-0.468015268006387507893896');
t('-0.54917290836787549931392', 88, 4, '-0.49990006636857985687649939062630289074578706968740926592041362893811220431493732027711');
t('0.91999661041886666', 17, 6, '0.72589581132601256');
T.stop();
})();

1039
test/modules/times.js Normal file

File diff suppressed because it is too large Load Diff

362
test/modules/toBinary.js Normal file
View File

@ -0,0 +1,362 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toBinary');
var t = function (expected, n, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).toBinary());
}
Decimal.config({
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', NaN, 20, 4);
t('NaN', 'NaN', 20, 4);
t('Infinity', Infinity, 20, 4);
t('-Infinity', -Infinity, 20, 4);
t('Infinity', 'Infinity', 20, 4);
t('-Infinity', '-Infinity', 20, 4);
// Integers
t('0b11111111111111111111111111111111', '4294967295', 32, 4);
t('0b100000000000000000000000000000000', '4294967296', 33, 4);
t('0b100000000000000000000000000000001', '4294967297', 33, 4);
t('-0b11111111111111111111111111111111', '-4294967295', 32, 4);
t('-0b100000000000000000000000000000000', '-4294967296', 33, 4);
t('-0b100000000000000000000000000000001', '-4294967297', 33, 4);
t('0b0', '0', 1, 4);
t('0b1101000100001000000110100100011100000101001', '7182272837673', 43, 4);
t('0b1100', '12', 4, 4);
t('0b101001110010100101010011101100111001101001100111101111111000101011011111000010011111', '12630360807685587318206623', 84, 4);
t('0b11111001010110010000011011010110111010011011110010100101011010010000111011110110011011011100001110000001110010101000001101', '5178750376444939350710857550952606221', 122, 4);
t('0b100110', '38', 6, 4);
t('0b101010011010001001110001110111110010010100011100110100001101101110100100001101001', '1602153026925525548353641', 81, 4);
t('0b100100101111011101011001111110000010001001100010101110000010010011111100100011110010001010000110100000010111011111110', '95386528077312833528510117745536766', 117, 4);
t('0b111111101111110011111000011001110101001101110000000011000', '143545575800234008', 57, 4);
t('0b111011100110001111100001101100100100', '63992372004', 36, 4);
t('0b101111111110', '3070', 12, 4);
t('0b1010001000100010110011010000100001000001111010001100001000000001011001110100101110101000001010001110101011100111111100100001010010110010000011001000110101100011100000110001', '3791391092894496185657389426598978260806574313715761', 172, 4);
t('0b11011011001101101111100101010011000101000100', '15064322355524', 44, 4);
t('0b10000010110111110100000101001001001011110100001100011111011011000110110011100000000101101', '316429297174908011263148077', 89, 4);
t('0b10010111000101010011011101101001010010011100110100111100001', '340208393737103841', 59, 4);
t('0b111111100100110000000000001000101001001001101101011000001011100001010001100110111110010111111101000100000010001001111000111011111000100101000100000100000001111100011011101011101000', '1522300117779563676992926268294212750701795813499189992', 180, 4);
t('0b111111000111011011001001111100100111', '67770294055', 36, 4);
t('0b100110111011000001111100110000100110011010001010000000100000011101101011110100000100010110011101001000010000100101010101010011111010110100011101', '13562459849657731179062132755251654390951197', 144, 4);
t('0b101100010010', '2834', 12, 4);
t('0b1111111011110011111100001011100110001010100001111100110011010001101011000001000000001100000011101000111101100011000110111111110111111111111111010101011', '2842819740151363791267849959009928040708832939', 151, 4);
t('0b100110100000100110110110010101000101011000001100010101011110100101000010101001100000001110111010100101010010', '195266285040805814110355923380562', 108, 4);
t('0b11111101111011111000010011100001100110110110000101100', '8934565388446764', 53, 4);
t('0b111101011111010111100011011101010001111100010010110111101111010111011010000', '36297363457553334775504', 75, 4);
t('0b1010111000111110100011011011100101010011110000101011000000010000010011101001010001111101111001110000010100010000111100100110001011001011110010100010111010010010100', '7958075089772384277251993017934409136873707500692', 163, 4);
t('0b11101000111010011101011001100100101001110111101110110100011001011111101111100100111011111100010011101111001010001100', '75584728662217792152893436906631820', 116, 4);
t('0b10011010111100000001000010101000111000100111', '10647241395751', 44, 4);
t('0b1101001000000100000001010101100110000010101111011111001011110100000010011011101011110011000111101001111001101110110011000101001101100111011111111111011001111010000000000', '613876598207563084074184752663166261629198587982848', 169, 4);
t('0b1000100010101010011110010010110101110000011100110', '300531517677798', 49, 4);
t('0b10100001111011110000000110100110101010010101001001111011110000101000110111000010000000100010111011', '200464110595405607835630307515', 98, 4);
t('0b101001100001010001110111111101100110001101100111011011101110000011111111011100', '196072603810916493443036', 78, 4);
t('0b111000100110111111111101111111100010111000011111110101000111011000110010110000100100010110010100101000101000111100010011110101010011101110011011100', '157803884622143105853315584471057717069995228', 147, 4);
t('0b110110010011000000100001111100110101001101010111100100111001000111000001011100011001111011010100100000010100101101110000110010', '72173098483072489213930426080106306610', 126, 4);
t('0b11010011001001100111100101011100111011011110100100', '928648793405348', 50, 4);
t('0b10110011010100010000101111100010111', '24067464983', 35, 4);
t('0b1011010001011000101010000000000110111101010000111101010101000011001110001001011101011100001101101110011011110101101010011000100110101111', '61368670450547755504412274420309228620207', 136, 4);
t('0b1000011111100010111001111100000100000000111001111111100100011100110101001010011010100111110100101001000100101000100010100000001100111001001101001110011111100000000111001010010111', '203364476148734435560803274724374642023080004086166167', 178, 4);
t('0b11011010100100111010010', '7162322', 23, 4);
t('0b10000100100110110001000101100111011100111010011011001101110010111100101111001001100001', '40077624010777577544413793', 86, 4);
t('0b111', '7', 3, 4);
t('0b100100011011111000010110101011000000011101100010001110110111', '656366019324289975', 60, 4);
t('0b1100', '12', 4, 4);
t('0b100001010110000111111010000011000100111100000100011111011011010010110110010010100101001100001101', '41279952929416973510169481997', 96, 4);
t('0b10101010101111010010000111011111110100001010110000111101100', '384469593819013612', 59, 4);
t('0b101100000001000100101100001000111011100010100111001101110011001101100111001001001011010010110010111010011111110100110100110101100001001101110100011100000100011', '502582666714640400473511879468920658557790730275', 159, 4);
t('0b1000101011', '555', 10, 4);
t('0b101011100101101001010111111110010111011010010100010100110101000001001101111111111111010111000110111010001010101100101101111001110111001101000010101110001010111011010', '31852131995136650015824448712052459356282756208090', 165, 4);
t('0b11010011110000101001111110011100100101011000110001000000110001110011011010110001010101010110100001010110111011010001100100001110001101111011', '1152932454441681553686105050801467624055675', 140, 4);
t('0b1100000001001001000111010001111010010111001011100111101110000101111110001011111', '454021537654527488097375', 79, 4);
t('0b1101001101000111001011011000010111000111110010011011101101011101011101010011001100100111000010011100111001101111100010011001011111111100001110010001001', '2355828849861155012884780223410671381544574089', 151, 4);
t('0b1010101011001011000110110010001011101011111101100', '375578620712940', 49, 4);
t('0b11101111110110011011001010101101010000001100111010010010100101', '4320760375549338789', 62, 4);
t('0b111001110101100110110110001001100011101011000110110110001110111111010110110101110010100100001101101100111011011100110000110111100000011100011', '2519183162360903506191281057447758087831779', 141, 4);
t('0b11100000111001110001000011110101010101100011', '15455189161315', 44, 4);
t('0b10111010101101', '11949', 14, 4);
t('0b10010111010010010011111011111011000101100010011010101110111000010', '21802627242312687042', 65, 4);
t('0b111100101010101010000101011000001001110000100110111000010111110010111101101000110111011111101011000001001101111111110111011100010011100011111', '2642399810851701674212632837439227993925407', 141, 4);
t('0b110101010010011100111000100001100100101101000111000001000111101010100010010111001000001100001100100100101111100', '2161630318713979730472184517642620', 111, 4);
t('0b11001101011011110101111100000111110011011001101110110010101100110101100101001111100101100110110010010001110001100000010011100110010101000011001111001001000111101000010', '150121826439470624887536282475629271619430756159298', 167, 4);
t('0b101111000010001110110001111111100110010111000100010100010111111100100011010110101011110000010000100001110011100101111010011100111000100010000000011100110111000111', '4296345185753731570217826010182320032993209601479', 162, 4);
t('0b11101000101000110001101001011101110010011110011101011011011001001010011111100101110101110011000100111001101111110101100110000000000111001001001101', '81062205635532331055236284929003822323364429', 146, 4);
t('0b11010111', '215', 8, 4);
t('0b10011000011011101000011000001101011000000110000101101000011101011110001010011100100011', '46069664430530648537081635', 86, 4);
t('0b1111101001110000110010000000001001000111100111000100101111101110001100001000100001010001010011101000111101000100000100110001010111110000001011010011011', '2792505467580338130476655688091490969863067291', 151, 4);
t('0b1111101100001101110000001101101111010010011111111101100000010111010101110110101100110010110010101000010100000010011110100100100111101010011', '683433243524982240677777243476582452055891', 139, 4);
t('0b1010101110101110001000111100111001110011001010011111001111101100', '12370864596035695596', 64, 4);
t('0b11000111110001100111001010011110011010110101010010111100011010111100101101101101101010', '60378345252763661786864490', 86, 4);
t('0b10101100111000000110001100101100001101101011010000111101100001111110100100011001000001010110001001110011111111101111111000000000000010000110110100111011100010001000100', '126329653589454952926638707222811823179996994585668', 167, 4);
t('0b111001000110000010011110111001000111011101011111100111110111111101100100110010001000011001100001000111010000010010110010110100111101000011110000111', '159155836031631574967766651303670498797193095', 147, 4);
t('0b11000110000110100101011010000011010110100101011000011101010000011010110001010100011110011100010100111111010110000101110110110110100000', '16852729444979725339524623444714796314016', 134, 4);
t('0b110100000100110000001100110011111010100011011111011101010011110100011001010101001001100111', '1007262826627701209829823079', 90, 4);
t('0b1011010110011101110010000110111110100010011000001', '399378554504385', 49, 4);
t('0b10110001001001000101010101010000101101000110100110000110001000001000010110100111000110101000010010100111010100011000100011101100111001110001010100000', '493799621713705665209661337050845053741490848', 149, 4);
t('0b10110101110101110100000111010001011000111011010000101001110101111110110001011000000', '6869753008454091059192512', 83, 4);
t('0b11101001010111011000000010011000001110011111110011111000110011110011001111011111101111000100010110001110100101', '1183302363719122225851040665789349', 110, 4);
t('0b100011010000101111111110101011111111100111011111111000011101110010100000110001111000111100010111011110000101010100000101011100', '46870857086354303302378526158318027100', 126, 4);
t('0b1001011100111010011100011010100000000100011101001101110110110010110100011001101000011110010000101110110101111110000000111100000101110100010100110100110001000000010110100011', '3536326453156193038031587123790239903142359400187299', 172, 4);
t('0b101010100101101101010110000001111101000100001110000011010001', '767218737556283601', 60, 4);
t('0b10110110001111010100100101100010111000001010000111100100011110001011101000101100111001111011100111001111', '14438492881715694934558943721935', 104, 4);
t('0b11110110001010000001011100110100101010001101010100100101000010101010001111101101110101100110100000111100101011001000010000000001101111', '20940687968317900181954981756671243649135', 134, 4);
t('0b11000001011111101100110101100110', '3246312806', 32, 4);
t('0b100000110100001011111111101000110001111011011011101111101001100001001000011010001111001111001110000100110001011000010111101001110111', '2791627903658830465325077767573756541559', 132, 4);
t('0b11011110001000000010111111000000000100001001000010010101111100110101100100011011011001010100011101000101100001110000001001010011000100101010101010011', '619196159474080554644191332764720245730596179', 149, 4);
t('0b11111111100100100000010101000110100110011111111000001001001010000111010110011011100001101011011', '39547602794153772246742451035', 95, 4);
t('0b1001001001110110001', '299953', 19, 4);
t('0b10100100101101011011010101000101001101001100101010110111110000100000101010011110010110001001001101000010001110110011110000111100010001001001101011010010', '3673151219411926241066396539539895097311402706', 152, 4);
t('0b111011100011111111000011011010110010010000111010100111001111001101110000', '4394919723391067681648', 72, 4);
t('0b1110011001100111011111001110111110', '15462167486', 34, 4);
t('0b10001001101001101101010110001101011101100100001010101100000010000100001100000010101001101100101101011100101101111000110110010010001001001101100100110110111101011000111000110100', '51501613866007552548575243188268697652335512286236212', 176, 4);
t('0b1101010000000101100111011110011110010', '113828412658', 37, 4);
t('0b11000010110111101110', '798190', 20, 4);
t('0b101001001111101100100111111000110000111010000', '22674826617296', 45, 4);
t('0b11100101111101100010000001111110011001100101111111111100000001101001011000100101000011110010111100001111', '18219421810715473011424793407247', 104, 4);
t('0b100110101000101100100110100100100100111110100000100010110001111100111100000011111001100110011111111010100100001100011000110110011111001100001011000111100001000', '441143871171700310794467845617284706136179969800', 159, 4);
t('0b111100111101101111000010110010101', '8182531477', 33, 4);
t('0b111101', '61', 6, 4);
t('0b11101010000101100100100000011100101111100011001011010011001011011100110100011100000010011111010110010000001001111011', '75965586951977951466854946826683003', 116, 4);
t('0b11111010111100001001110010100011011111111011001010000110011000010101110010100101110100110110011010000011110011101110011100011101010000011001001010000001011100100', '2865227033411954606371792440103294708104730837732', 161, 4);
t('0b1100', '12', 4, 4);
t('0b1000000110001111010010110000101010101011101111101011011101000000000101010100011100', '2447314272063451666863388', 82, 4);
t('0b1101000010010001111110110001011000000001101111000111011111000110', '15029069503449036742', 64, 4);
t('0b1000100101100110011011000000101101001110011', '4721031010931', 43, 4);
t('0b11111000100111111001100001100100010001100110001101000110101001111111011011101010110110110101000100100101001100010011010110100100000101010010011100111000011100111010000000110011', '93021064714003304999209676659750808550526701882548275', 176, 4);
t('0b111111011110010111011101011101101101000100110001011011111001', '1143454535228004089', 60, 4);
t('0b111110101010110100000011111001001010111110', '4306578150078', 42, 4);
t('0b110000100010000111110110110111100110111001001001111000110', '109286979318617030', 57, 4);
t('0b100001011110001110101100101110001101010010011110010010101101110110001000110101011101101000101101111110110111001111100101001000000001101010100000011111100011001000101000', '195679510499172126937950972652289628431931810918952', 168, 4);
t('0b110001011001101100010101001101000111101010000010111101011011011011011101100', '29161467826175673743084', 75, 4);
t('0b11111111110110000000100111111010011010000000001001', '1125213381697545', 50, 4);
t('0b111011110101010010011000011101001010111001100000000110110111101110101110111000101011101000000001000110000111010000111101100101000011000000110', '2606077838126325794622812111329148470986246', 141, 4);
t('0b1110110100000000001111001111001010000000000111000001000100000111101001001000011010100101100111', '18337058785747772841230707047', 94, 4);
t('0b1011001010011111110101100010010100111110101100001000111101111010011011101110001110000000101101010110111100001110000111111010110001000111011', '486261763761604150405408746183250518303291', 139, 4);
t('0b1110011010011010101000111100111010101111000001101010001110110001111110000100001001100011001100101100000010110110111000010000110001010', '9808812004949753301944141481962869891466', 133, 4);
t('0b101010110001010111100100111111100000100011001010110100111000011010101000100011110110111000111000010011000101101100101101101100001000', '3638586720469021421571505782203805260552', 132, 4);
t('0b1101111001100', '7116', 13, 4);
t('0b11111010111011101001100100100011100010110011000101011100', '70631085671395676', 56, 4);
t('0b1101001100111000100111000111101111110101101110011', '464480193997683', 49, 4);
t('0b11011100010001001111010010110101001000001111000100101001001010111111001100011101011010101101110001001011101011100011100010101110100101010100111110101110011011010110011000', '1287696114982305806708561003677255537140522028742040', 170, 4);
t('0b100110001011101010111011011011101100111001111011000', '1343422207521752', 51, 4);
t('0b1110101110100000101011000101111100101001110011100100001000110010001101110011101000011111101000110100011100101110000101100000010000100110001001', '5131515373500601241098729740846521305336201', 142, 4);
t('0b10011101000011001000111010000101011111110111011101101001010010011000111101100010110010100011010100001000000001100000000011000010100010100001011100', '54723606892902481536500944335964133487421532', 146, 4);
t('0b1101001110111010100010011100001', '1776108769', 31, 4);
t('0b100000001100000110111101111110000001100110101101000100111111001110011100010111101101011000101010101011111100000001010101111111', '42786787446528052699594039883348317567', 126, 4);
t('0b11000011111111011101011000111101101110010000101101000010101110101011', '225962873073433848747', 68, 4);
t('0b111111100111001101011011100101111010010110100110011000000000010110100111100011', '300402265535819852900835', 78, 4);
t('0b100011111010111011011011111', '75331295', 27, 4);
t('0b11000100111000000111011111010101000010111001', '13529272635577', 44, 4);
t('0b1001101100100010000010100000000111000110011111111000111010110101001000011101100011011101000100011110111100000110101010011010101110010011000011100011001', '1729790364338742795479957074258010329122965273', 151, 4);
t('0b110001101', '397', 9, 4);
t('0b10011100001001100111110000111', '327470983', 29, 4);
t('0b10100101011', '1323', 11, 4);
t('0b1001100110010000000111010100111101011110101111101000110100', '172896507987163700', 58, 4);
t('0b10110101100110011101011011001111000000100011011110001110101100110111011111000010010101100010100110101101101111011', '7366609054351701610086110120336251', 113, 4);
t('0b110110010111101111010001001101010001011101101010001001001101111111011', '501483179338306460667', 69, 4);
t('0b10101110110111001100101001110000100100101001011100101010111010101110010000000100001110', '52848936898297944277057806', 86, 4);
t('0b110100101110001101101000000010100010010010000010110011110111100110111001010010111000101100100101111001111000011011100100011110101100111110001101011011111100', '75247462135135296147483304900271494532907456252', 156, 4);
t('0b1000100111100011101111100111010111110011101110011001100111111000011001010010101011', '2604661372805165686559915', 82, 4);
t('0b110000000011011011111101100001100000010100011110111001010101010000111000010000101110010100000111000000010110111011111001011011110111111100111101111010000', '8573066822280330509997029656969204484303387600', 153, 4);
t('0b1111000010000101010011110111001010001110101010010110011011010110110001101100011001101001101', '2326173895977887311754310477', 91, 4);
t('0b101010110000111000011000100111111000000100110110', '188077030998326', 48, 4);
t('0b1000001000110100001000111000111110101100101010100100110111000001000011110011010001100001101010001101111111010100001100011110010100101110000100001', '22684678246378182819785716745165465876847649', 145, 4);
t('0b1101100111111101001001001100011001000011101001001100000001000111110000101001100010011011011100101100000010001000100110010111111010011111000000001000001001011010101111110101', '5097456801022432585476312678303126165684672742665205', 172, 4);
t('0b1111000101001100001000111101001001110001110000011100100101000000111001000010100010000110110100010001011010101001000011000110010101000010001111001110110000100110110000111011', '5642505228059227244247414269863757684704851232189499', 172, 4);
t('0b11100011100111110000110111101111011111110001101101110101000110101100011100', '16795487938751986166556', 74, 4);
t('0b11111001101101111001100110000101001000001111100100001011001100101100100001110100100110010110011010100111100010100111111110101000100110001011011001011000101011101000001011011', '11678786451764002081049400473764762680882990476021851', 173, 4);
t('0b11101001011010111111100100000111101100010100011100001111011010010011111011011101000101001010111001100010001100000110000011000011010001111110010001101100000100010000111', '170573148533121700284914386034471572584747624695943', 167, 4);
t('0b10001100111100111110001010', '36949898', 26, 4);
t('0b1010010100010010011110001110011111100001', '708979517409', 40, 4);
t('0b11101000001111110011000101110101110011011011110110011110000000111111111011110011101111110001110101100100101111111100010101010011110011001110001010010011011001000001000101000101001', '695150897721330668961198822938644201466146242961639977', 179, 4);
t('0b100011011001101111', '145007', 18, 4);
t('0b1100001010011011100011011010100011111100110100001111', '3423573638106383', 52, 4);
t('0b1101110000000101010111111111010', '1845669882', 31, 4);
t('0b101111100111001010111111110111111000111100111111110001110011', '857702623840828531', 60, 4);
t('0b10100100001000010111000101101101000100001', '1409871436321', 41, 4);
t('0b1000101011', '555', 10, 4);
t('0b10010011010001101011011101011000110001101001001001000000111111101101010000001110000111011001101110100011001010001000100001010101000100010000110100010010', '3284369793875476139142406227062347521500187922', 152, 4);
t('0b111010010000011101100011000010100001011001011101111110001001100000101101100111111110110101111100011111000010101110101001010001011010', '4955975645658396849750021048094688973914', 132, 4);
t('0b1100100010101100010011010111010011011110001010011', '441284718869587', 49, 4);
t('0b1010110010000010', '44162', 16, 4);
t('0b101110100110000101110000101000000100100110110100000101100000011001111010111100011101011100101010001001010011001101001010001', '7741948260639498696423377430502808145', 123, 4);
t('0b101100000110111000111001010110010000110011', '3031053984819', 42, 4);
t('0b10110011010101011100010110100101111101111101110001011111101011011001101100100010000001010011011110010010010011101010001010011100101000001000000001010100111011111110001011', '1048393860009702438276451118840918885709561673793419', 170, 4);
t('0b11011000100011101011010010001001101010111010000100000110100010011010100100101000110011001000000101100101', '17157448231253463055811180527973', 104, 4);
t('0b1001111101111001100110000011001', '1337773081', 31, 4);
t('0b1010000101', '645', 10, 4);
t('0b111110000001000011100000110010111011001011100110111110011110111011010101010111101100101111101000000000101100011111110111100101001110000011111000010011011', '11064110199645779468713657128408705698455744667', 153, 4);
t('0b11110010010110011110011011000110111010', '260222595514', 38, 4);
t('0b101000100111110011111100111001011100001000101101110011000100111111011001111', '23979030927343490334415', 75, 4);
t('0b101000000010010101101101001010', '671701834', 30, 4);
t('0b10011100000110011001110110011111011101110001101011110111110011000001100001000101110111001110000010011101101001010111010010010101110111110110110000010111110111011010', '14258780956329408244620868751517156468304535191002', 164, 4);
t('0b10011010111001101001111000001000011000111000010111000100011101110000111010000010101010', '46815908925437602817089706', 86, 4);
t('0b1100010000000010001100111000011111100010101000010101100001010100011101111001101000001101111111101101000100', '62117604478929274751724622969668', 106, 4);
t('0b11100010001001100001', '926305', 20, 4);
t('0b1110101110110010110010101010010011001111111011011000', '4146450184077016', 52, 4);
t('0b11100011100000111011000000111111001001011000011011110001011110010111101001001001000011111101000000011111101001111000010101001011100000010100000000001000000101001100101110110', '10640405756706933069932552513853268918056402456582518', 173, 4);
t('0b100000010101', '2069', 12, 4);
t('0b101000101100101111110110100100001110100101001010010100101010001100001101100011110110001001111110010010110100001011101101111010100110000000110100110101000', '7260976836577029672818019365254002054979938728', 153, 4);
t('0b1010010010100000101011111111110100000011101101000100100000111001100000010101011011000011111010111001000111011110101111010000110', '109413864136821966738078269201594670726', 127, 4);
t('0b11101001010010010000001010101001000010111010011111010011101101000010110', '2151676161178286545430', 71, 4);
t('0b1', '1', 1, 4);
t('0b11110110100000100001101001110011101100010110000110011101110010101110101010111001001000101011101101100000010000100101', '79996489761592791530139097880724517', 116, 4);
t('0b1101000110', '838', 10, 4);
t('0b11010000111111110000100100100110100000110001000101010100111110', '3764941434990646590', 62, 4);
t('0b1100110001010110001011110100101011101000110000011100010000110010010111010010001101111000000111110101100010111000101101001101', '16975625492382937650444877242569558861', 124, 4);
t('0b1110110111110101110000001100101101010101101101111111011001101011101101000010010010111101010011101111011011011110001111000001100001010010011001111010010110001001111111001', '695557780484633047451419090913265350682286538560505', 169, 4);
t('0b10010011101100000110011111100100000000101001100101000101111110001101010110000010011010000001000110010001001011011001110011000010111001011110110', '6432766911463399701129205956556722425393910', 143, 4);
t('0b10000010011101010000001110000110011101010111100000111010010011100001100100', '9626033841394783172708', 74, 4);
t('0b1101101000011111101101001000111', '1829755463', 31, 4);
t('0b111010100011110110011011011111000100011011011111000010110000110001101011001100010110100011110000', '72493971032499161046675712240', 96, 4);
t('0b10101010100001111110010100000111110011000010111011011111', '48000163788893919', 56, 4);
t('0b111001110111101101111011001110001110011111000010110101101', '130312977572136365', 57, 4);
t('0b1001110011011111011001111000011011000100000001110111000110110010001101010010011000100100001100111001101001100110011110001111111111110111101111010', '27331074366810509421853388280769875793670010', 145, 4);
t('0b1000001110110010010010110000001010001001011100000010100100100100000001011101001101100100001111000010', '652129268908332354914162721730', 100, 4);
t('0b1100000101101000011101100101011100010111010011001000100000101101100111000010011000001110011111111111001000101110001', '31382251255391898419590799476887921', 115, 4);
t('0b1101111011001011000101110110110111011010111100010110001110100111000010001101101001100011101001101101101110001101110010001110000000001111', '75812640390549515698067392896804260995087', 136, 4);
t('0b1101010000010110111100110000100010111001101110110100011101001010100111100101111011100110000111000011011000101011110010111011101110001011001001101000101', '2364878576296174981737730111388996744591545157', 151, 4);
t('0b1101111111100100101111001111011100000100000011110011111111010101100100011011', '66081699980324911274267', 76, 4);
t('0b1110000110010101101101001100110011010000100001011100100111001010010101111000000101101111101011101100000001000110000110101111111100100000101111', '4912801682953604186696386732310079951849519', 142, 4);
t('0b11000101100000111011101101001000010010000011100010010110011000111110110101110110100001100110100100000100000000010111010', '512777157413030085980733281858093242', 119, 4);
t('0b110010000000100010010100110100001011001001100010001111011010100000', '57655736925864654496', 66, 4);
t('0b1001000100111010111111000011101100000010001110101111111011000110010001010001111001110011001', '1404582351453280869403915161', 91, 4);
t('0b100110101110100011110010101100010111011111101000111100001110000101011100010100111101100000011010001100111000011110', '12567788490336688088992466604707358', 114, 4);
t('0b110111110010011110110111001011100010001010100001110011111111111101110001000101111100110011100110000100010110010011', '18104495725933236784651084181816723', 114, 4);
t('0b1111000110100000011101011000111010010101011101010010110110111000010101110110110100010000110000001101101011011001101101101100100110110110111100011001100110010010000100010111011', '45201658205192969951078809960368998187352382503454907', 175, 4);
t('0b11110111101000011110000010001', '519322641', 29, 4);
t('0b10100000110110110111011011110111110110111001000001001000100101000001110101001101000011111000100011011110110100111101111', '417609385350091179779636810113575407', 119, 4);
t('0b100001010110111010111000000100010101101100010111', '146710581041943', 48, 4);
t('0b10001111010011100001101011101100110111010100100', '78782810975908', 47, 4);
t('0b10001110110110100000011010101', '299581653', 29, 4);
t('0b1110001011001100001001100110001010000110', '974087676550', 40, 4);
t('0b11100011001001011111010000101001001011001001010110110101001110000000111010110100001000011100010011010011100011000010000101101001110100011101110011110111', '5065575398273300616873996741388922355920788727', 152, 4);
t('0b1111111000001101100100011000', '266393880', 28, 4);
t('0b10110101100100101010001010111001000000011100000110110001011100011111111100000110001001010101111111010011000011100011010001110110011101101100101111101101111110', '259149353365748547676531551540644422107339619198', 158, 4);
t('0b1101011110100010001011001011000010000011001011110000111100001100101100100010001111101111001110100011011000010000', '4373566857843294445861437353637392', 112, 4);
t('0b100011101001110010110011110100110011010000101000100111010100101001000111110100101011010101000001111110100000100110111001001001101010011010000101001000111000110111010', '26053480661633533853821712739093750512044053131706', 165, 4);
t('0b1110010101111000001010010001101011101010001111011001101000000111111111010000000001011000011001101111010101100001101011001100011100010011010100111000100011100110001111110010', '5365917928263298552573558618072276593881915061068786', 172, 4);
t('0b0', '0', 1, 4);
t('0b101101010011001101010001010001010000110000011111', '199232011439135', 48, 4);
t('0b100101010000010110110111111000101111000110000101010010001001101001101000', '2748976914400602004072', 72, 4);
t('0b1100010100011100010100101000101110001101001001010111100010', '221926845064713698', 58, 4);
t('0b111010011101110111001010101110100000001011000', '32142349779032', 45, 4);
t('0b1011000111100001011000110110010011101101', '763990598893', 40, 4);
t('0b111110001111011010110111001010100111111101111001001011010101110110110011010001110010101101000011', '77050543164333814857060526915', 96, 4);
t('0b110111110010111101111000100111010010001110001111111100001101100010001101000100100100011100100011011011010111010111001001001110100001100', '37973033900975016780110288277302266862860', 135, 4);
t('0b101000111010110010000111111000011000001001011001111000001100001001110001101100001111001000000000010111111101110011100011011001111111110100100010001110000000101101001110100', '1913677948341929506841492066019813618520908835609204', 171, 4);
t('0b1111101001100110010101010000001000100000101001101110110100011', '2255400303091572131', 61, 4);
t('0b110100010100001101111110100010100001100101110001100011111001010001101001100010011011001110110011000010100001001011101100001011101001011010000011001010001100', '74667765260706149423652281266282011954894090892', 156, 4);
t('0b1000000010111101', '32957', 16, 4);
t('0b1111110100011101111101100011', '265412451', 28, 4);
t('0b11110010', '242', 8, 4);
t('0b1001111110110111001001000000111011110010101101011001000011110110000001000000001101110010100000110111011000101111000100101111111001100001001100011111010100101100100', '7294509680489473516157489095568130945736908974436', 163, 4);
t('0b111101001100101010011001111111100101100011110011110', '2153208033232798', 51, 4);
t('0b101111100110101010011111110100000001110001010101110001000001101101101011111010100110011011011', '7366381587271251372942380251', 93, 4);
t('0b11100', '28', 5, 4);
t('0b10011100111001101100', '642668', 20, 4);
t('0b10100010111000011011100101000111000010110010000101111001111001111011101110110110100101001110100100111010101010111100100001001110110100100100100', '7094500064780213519639611108740313788148004', 143, 4);
t('0b111110111101010100110000011010010100100111110001111001101110110001011110001111011000011001000100110101101100001010000011000001000111010100', '342777004104073921541803082899350493073876', 138, 4);
t('0b11100011110111111101111100110111111000010011000000101100001100000100000011111110011001110100000111001011111111010110100111111011010101110011011011101000', '5081771157073840975382845753680003415619876584', 152, 4);
t('0b1110101100001100111010010101011010001101111001100101110110011101111101110111000011101001010011110110000100011010011001001100100010111', '9997939815383461009512050917690963695895', 133, 4);
t('0b10001010010011111111100001110010110100110011101', '76038037662109', 47, 4);
t('0b1101000011101001000100110101000110011011110000001000010010000011111000010000111011101001000010011111010011111111011111101101101110110110001011010111000000100001001000', '76330741559420840213970134181579220885370404866120', 166, 4);
t('0b101110101011111101011000011101001100011100000100001000110011101011011101110001101110110011010110010111100', '29591313602933764036329127652540', 105, 4);
t('0b110011101001000110010011100', '108301468', 27, 4);
t('0b10111010011000101111000011000000111000011100011010000010011000011101011011111000001100000001110001', '230735293932368005478672810097', 98, 4);
t('0b101110001011101011001000111000101100110110001010110111110010110111000101000010110100000010010011101000111001010010011011010', '7673368527850305306860702856736711898', 123, 4);
t('0b11000010011011000010100001001011111110000001111000101100100011011100000', '1793230956491923932896', 71, 4);
t('0b10101110101001011001101100000100111110111010000110100110110', '393269849358142774', 59, 4);
t('0b11100010011101010', '115946', 17, 4);
t('0b11110001000100001110011001100100', '4044416612', 32, 4);
t('0b11101111111000111000010010011101000110101000100101100010', '67522678144797026', 56, 4);
t('0b11100000110000100010000100100100000010001111011000011001101101101101001000010011101010011110110010101111010000001100000100100100000', '2390040390567048642966647388057001920800', 131, 4);
t('0b1010000110010110100110111100111101001001101101011001111001110010000110100010000000000101100011101100010011011000000010111111000110000001', '54985654283950555052147243853162465718657', 136, 4);
t('0b11000011100011000100111110110111001010010101000011001010010011101111010011110001101100110110001111011110100110010011', '63458983779334095341636694071699859', 116, 4);
t('0b101111100010001011001011101011100010010111010000111100101000010011100010100001001111001100010000111111', '3766029900593721359372665013311', 102, 4);
t('0b101111011000101011011011001000010010011111001001111010000111011111010010010100111011110010011100010011000111110011110110001010101100010110010110001111011100', '67630990462245519904689419770374213484683027420', 156, 4);
t('0b1000101000001110001001001111100000001100000100', '37948338602756', 46, 4);
t('0b1110100101100011001000000000001010011000110001010101101010010', '2102165078632082258', 61, 4);
t('0b11', '3', 2, 4);
t('0b11000000101111101111010110110101001110011010001011001011', '54253158045164235', 56, 4);
t('0b1011101000010110000100000100111001010100101101011011101001001011001111001100101110010100100011101011', '921454163161847327849553938667', 100, 4);
t('0b11011110010110101000111111000110101111000110111001001011111', '500696147126612575', 59, 4);
t('0b1010101001110010100011100110011111001011001010011010000110001101', '12282035710234042765', 64, 4);
t('0b1001101010011101000101110010011010001010101111001000000101010010100001100000110010100001000001111011011110001100110111101011111011000011001011000100000000011110001011111011', '3615489279593509708772217418002107077942788107657979', 172, 4);
t('0b1010010111011001111100100000011001101110111101110011101010110000011011001110010010111000000110101001101000001110', '3363864999018073552305148875414030', 112, 4);
t('0b10110111000011100000100001000111101011000010011100010111111001001110011000000111100110101111111111111011110110111010111011010000101010100111011000100110010111001', '2090116485561415533220743961894899901833660878009', 161, 4);
t('0b101001101001001011010001100010111111010000001111110100110010110011101000000011010111111110011100001011100011111101100100010110000001100111000010001111110', '7429426803493479456828449389493437652073153662', 153, 4);
t('0b10101101101111010111001110101001101001100', '1492415632204', 41, 4);
t('0b100011011100100000101110001000011111111010011010011001101001010010000011110000111011010001101011000010010000110110001', '92021749248802288107686447118623153', 117, 4);
t('0b10110001100100001110111010111001010011000110010100011010110010010100110100111111101111010110100110100', '1758529900728895870358045306164', 101, 4);
t('0b1001111000000', '5056', 13, 4);
t('0b110000111100010100101000011111110101000011110011111100111010010010001111001101100000001000111111100010010101100', '1985345177021823592895244450907308', 111, 4);
t('0b1001110000100000000000110110100010010101111110010100011100010101101010', '719999719481543869802', 70, 4);
t('0b111100100100001100100101001110001101011010010100011010011100101000000101011011', '286012825709225924788571', 78, 4);
t('0b11010111100100111111110100111001010000011101110110100000001100001100001011011000110100010110110001110101100111100111000110010100011', '2292419381743847793952323533642807872675', 131, 4);
t('0b100110100001101001001110101010000101110100000100000010100110001010101111110100110101001001001011011101000111001101100001101100010011000010011010', '13424243929007150060864059623182269932449946', 144, 4);
t('0b111011000010100011011110010000000000010110111001001100010010101101000001000010111010110001110010010101', '4677623609407056260314308484245', 102, 4);
t('0b1010001000000011111000000101001100001011100000011111111001101000100001001011010110000010011011111111000011110101010001110011', '13459691377936385656205820498694591603', 124, 4);
t('0b101111100101010010010101000010100111111101111011110111100110', '857171914848189926', 60, 4);
t('0b110110001001110001101001101001011100110000000100111101101000111101100100110101001110010001', '1047466460252578697656357777', 90, 4);
t('0b10000101011010001000100001111111001110010010110100011000111101001010000001001011001000111010010000011010101111001111101101010001', '177330090800059334179372876785623300945', 128, 4);
t('0b1010', '10', 4, 4);
t('0b1110000101111000100101111000000001000100111010100110100101100011001010000101101001100000000100101011101001110000001110011101000001110', '9590478319392434269891419865097211165198', 133, 4);
t('0b1101010001110100011011010010011010100010111111101000101011111111111011011100001000010100011100010000111011001011000101100010010001111011101111010100100011000010001', '9703219505953893074023234217532878016916428047889', 163, 4);
t('0b1101000001100011011001110000010011000100110001000011010110000100', '15015958852762088836', 64, 4);
t('0b11110011111110100111011111001010001010010100010010110', '8584226467555478', 53, 4);
t('0b11111001001000111101010101111010100110110100011001001110111101011011100101010101001111001011', '4819067998434611218882057163', 92, 4);
t('0b1000', '8', 4, 4);
t('0b101110001000011100101111000001100011100000100010101011101011110', '6648324064296392542', 63, 4);
t('0b100000001011010111010101110111110011000100', '2211226025156', 42, 4);
t('0b111000010011100011011111000001110100100', '483660891044', 39, 4);
t('0b1100110100110100011011000', '26896600', 25, 4);
t('0b1110110001001101110110101111110100001000011011100111000000100111110010011011000010011001111011101010010010111111101000001011011', '157051027737987715731727950696316653659', 127, 4);
t('0b10101101101110101011101100011100010010011011011011000110111000010000001001110111010100111', '420051957077295313153486503', 89, 4);
// Floats
t('0b111010110111100110100010101.1110000001100101001000101100010001111011', '123456789.87654321', 67, 4);
t('-0b0.000000000000000000000010000100100011111', '-0.000000123456789', 17, 4);
t('0b1111100111.11111111101111100111011011001000101101', '999.999', 48, 4);
t('-0b11111100001000110000100000101.010000000010101111110001111101011011111', '-528769285.2506705498654986754987694357629487612132293856', 68, 4);
t('0b111011.001010010001', '59.160508253119229720226315984803348705', 18, 4);
t('0b1000001001001100110111.101011101111000111000101011111000010001111111011100010001100111111100100011010100001010111111', '2134839.683376639182809009377393376566052153774412236905434', 115, 4);
t('0b110100110001101011110111011000010000110100000011111011110000111111110101000111000110001111011110111110111000010111001110000001101.1101111001111010101101110101011001000011000000101011010000001111011001101010010101', '561214248546542162784739085096665717773.86906', 211, 4);
t('0b10110111000101011010101011100011110110000011100101000100101000111000001101110001010010110011101100101000001100011111010111011100.000110111100110011011100001111010100110111000100110000100000010010100101100011001101', '243361227524012342673912659288240813532.10859467026399996528383947490', 212, 4);
t('0b110001011001101010010100100001011011001101010101111001010011100010110001001010010110100000111000000000001101000000110000100011100001101001100011010100110101111010110001.1011100011010100100011101101101100101011000110000110111110001100000110011000111100001', '288798319290142875873517012221913212736305288666801.721993378169914151', 253, 4);
t('0b101111111100000110101111100000101000111011101010001100001110', '863594881689232141.62881568577668460977625904', 60, 4);
t('0b101110011110011', '23794.501525', 15, 4);
t('0b1000', '7.792303494645702446763290630498884400068339335428470929289382355', 4, 4);
t('0b10110001101000000001011000001011111010111100011101101011011001001001011011010111110000111101001001110101110101011011011100010', '29513071238598351326634077220532565729.753116233815194468461197227952', 125, 4);
t('0b110010', '50.3', 6, 4);
// Include binary exponent.
t = function (expected, n, sd, rm) {
T.assertEqual(expected, new Decimal(n).toBinary(sd, rm));
}
t('0b0p+0', '0', 40, 4);
t('0b1p+53', '9007199254740992', 40, 4);
t('0b1.1p+8', '384', 40, 4);
t('0b1p+1', '2', 40, 4);
t('0b1p+8', '256', 40, 4);
t('0b1p-6', '0.015625', 40, 4);
t('0b1.10110111p-1', '0.857421875', 40, 4);
t('0b1.10110111p-1', '0.857421875', 9, 4);
t('0b1.001010101110101p-4', '0b1.001010101110101p-4', 16, 1);
T.stop();
})();

534
test/modules/toDP.js Normal file
View File

@ -0,0 +1,534 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toDecimalPlaces');
function t(expected, n, dp, rm) {
T.assertEqual(expected, new Decimal(n).toDP(dp, rm).valueOf());
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 7,
toExpNeg: -9e15,
toExpPos: 300,
minE: -9e15,
maxE: 9e15
});
T.assert(Decimal.prototype.toDP === Decimal.prototype.toDecimalPlaces);
t('0', 0);
t('-1', -1);
t('9.999e+9000000000000000', '9.999e+9000000000000000');
t('-9.999e+9000000000000000', '-9.999e+9000000000000000');
t('1e-9000000000000000', '1e-9000000000000000');
t('-1e-9000000000000000', '-1e-9000000000000000');
t('Infinity', Infinity);
t('-Infinity', -Infinity);
t('NaN', NaN);
t('Infinity', 'Infinity', 0);
t('-Infinity', '-Infinity', 0);
t('1', 0.5, 0);
t('1', 0.7, 0);
t('1', 1, 0);
t('1', 1.1, 0);
t('1', 1.49999, 0);
t('-0', -0.5, 0);
t('-1', -0.500001, 0);
t('-1', -0.7, 0);
t('-1', -1, 0);
t('-1', -1.1, 0);
t('-1', -1.49999, 0);
t('-1', -1.5, 0);
t('0', 0.4, 0);
t('-0', -0.4, 0);
t('-0', -0.5, 0);
t('1', 0.6, 0);
t('-1', -0.6, 0);
t('2', 1.5, 0);
t('2', 1.6, 0);
t('-2', -1.6, 0);
t('0', '0', 0);
t('-0', '-0', 1);
t('-0', '-0', 1, 0);
t('-0', '-0', 1, 3);
t('-0', '-0', 1, 6);
t('0', '0', 10);
t('-0', '-0', 20);
t('0.000000000001', '0.0000000000005', 12);
t('0.00000000001', '0.000000000005', 11);
t('0.0000000001', '0.00000000005', 10);
t('0.000000001', '0.0000000005', 9);
t('0.00000001', '0.000000005', 8);
t('0.0000001', '0.00000005', 7);
t('0.000001', '0.0000005', 6);
t('0.00001', '0.000005', 5);
t('0.0001', '0.00005', 4);
t('0.001', '0.0005', 3);
t('0.01', '0.005', 2);
t('0.1', '0.05', 1);
t('1', '0.5', 0);
t('0.01', '0.00001000', 2, 0);
t('0.0039', '0.0039', 4, 3);
t('-41620.65299', '-41620.65299', 6, 5);
t('0.0011117', '0.0011117', 7, 0);
t('938116', '938116', 6, 5);
t('-7187', '-7187', 4, 4);
t('-2.4263', '-2.426346', 4, 6);
t('-0.537', '-0.5374743', 3, 5);
t('652506', '652506', 3, 6);
t('-178587', '-178587', 3, 2);
t('4093', '4093', 3, 0);
t('44', '44', 1, 2);
t('-0.0496', '-0.049635', 4, 4);
t('-1', '-0.05', 0, 0);
t('520216039', '520216039', 7, 1);
t('-2932289', '-2932289', 8, 3);
t('53937.3', '53937.399', 1, 1);
t('63101619', '63101619', 5, 0);
t('-0.00207', '-0.00207', 6, 0);
t('-0.032', '-0.03169086', 3, 0);
t('-755', '-755', 5, 3);
t('-3583', '-3583', 5, 1);
t('-6.616', '-6.615375', 3, 0);
t('7528739', '7528739', 8, 0);
t('-0.9028', '-0.9028782', 4, 2);
t('-8.78762908', '-8.78762908', 8, 2);
t('-0.000262', '-0.0002613', 6, 0);
t('-888980.3', '-888980.3', 1, 6);
t('0.00009075', '0.00009075', 8, 0);
t('-4.42', '-4.4195', 2, 0);
t('-0.336889', '-0.336888682', 6, 6);
t('43759', '43759', 6, 4);
t('0.0000804', '0.0000804', 8, 6);
t('-4', '-4', 0, 2);
t('-3', '-3.614204', 0, 2);
t('336379823', '336379823', 4, 1);
t('310614', '310614', 7, 0);
t('-375811635', '-375811635', 8, 3);
t('-5446775', '-5446775', 7, 4);
t('59.7954405', '59.7954405', 7, 0);
t('47086', '47085.84', 0, 4);
t('-2564', '-2564', 3, 4);
t('1.4069997', '1.40699967', 7, 2);
t('-0.4', '-0.42528874', 1, 6);
t('-0.00005573', '-0.000055732', 8, 1);
t('-0.00003014', '-0.000030137', 8, 6);
t('57', '57', 3, 6);
t('365474.9164', '365474.9164', 4, 5);
t('-7', '-7', 0, 4);
t('0.843206', '0.84320562', 6, 5);
t('-62734', '-62734', 5, 3);
t('-51246', '-51246', 7, 2);
t('0.0003', '0.000332', 4, 5);
t('-609', '-609', 2, 0);
t('-0.00004595', '-0.00004595', 8, 1);
t('-22243', '-22243', 0, 1);
t('54693', '54693', 5, 0);
t('5', '5', 1, 6);
t('2', '2', 2, 6);
t('3808', '3808', 0, 4);
t('2616', '2616', 0, 5);
t('-2477', '-2477', 3, 2);
t('0.00009', '0.00008892', 5, 4);
t('8.8953', '8.8953', 5, 5);
t('0.07', '0.06922', 2, 4);
t('0.08', '0.08', 3, 2);
t('-773.0965536', '-773.0965536', 8, 2);
t('-326', '-326', 2, 1);
t('-0.356', '-0.3564473', 3, 6);
t('-312283993', '-312283992.7', 0, 3);
t('-2.3995861', '-2.39958606', 7, 3);
t('-0.0449', '-0.0449', 4, 3);
t('-0', '-0.003', 0, 4);
t('85942', '85942', 2, 5);
t('6738', '6738.1977', 0, 3);
t('-0.003', '-0.002995', 5, 3);
t('-572936', '-572936', 3, 6);
t('684.2426407', '684.2426407', 8, 6);
t('-0', '-0.0007851', 1, 6);
t('-0', '-0.002', 0, 5);
t('85.05', '85.05', 3, 3);
t('1.66', '1.66', 3, 3);
t('-17.14', '-17.14', 2, 0);
t('80182', '80182', 6, 5);
t('-0.00064', '-0.00063953', 6, 6);
t('-3.76703298', '-3.767032983', 8, 4);
t('-0.000378', '-0.00037877', 6, 2);
t('675', '675.76294', 0, 3);
t('0.0003', '0.00023235', 4, 0);
t('-0.0155175', '-0.0155175', 7, 0);
t('-645406477.5', '-645406477.5', 2, 1);
t('-0.89603', '-0.8960278', 5, 6);
t('866034', '866034', 7, 3);
t('484.002', '484.002', 4, 6);
t('420', '419.83', 0, 6);
t('4611867124', '4611867124', 4, 4);
t('0.0080252', '0.0080252', 8, 0);
t('-0', '-0.02829833', 1, 4);
t('-8', '-8', 0, 4);
t('-0.0073554', '-0.00735541', 7, 4);
t('28', '28', 3, 5);
t('-3903', '-3903', 6, 0);
t('228', '228', 3, 4);
t('0.88', '0.883', 2, 5);
t('-0.01', '-0.009', 2, 3);
t('7796.6', '7796.6', 2, 2);
t('0', '0.005', 0, 6);
t('805.25', '805.2467', 2, 0);
t('-85023', '-85023', 4, 3);
t('-0', '-0.008097491', 0, 2);
t('-0.026', '-0.0259', 3, 4);
t('-0.00801', '-0.008007359', 5, 4);
t('30745', '30745', 6, 5);
t('-81', '-81', 4, 6);
t('-386', '-386', 4, 2);
t('-2876', '-2876', 5, 6);
t('0', '0.00002329', 4, 5);
t('-62453828', '-62453828', 7, 6);
t('0.317', '0.317', 3, 3);
t('-706', '-706', 0, 1);
t('36.911', '36.9109527', 4, 4);
t('5040908', '5040908', 1, 0);
t('-0.08', '-0.08', 2, 4);
t('-0.352847', '-0.352847085', 6, 6);
t('0.001', '0.00006', 3, 2);
t('-0.4389', '-0.438905', 4, 1);
t('0.00390964', '0.00390964', 8, 2);
t('-35105.1', '-35105.1788', 1, 2);
t('-8858843.829', '-8858843.829', 3, 1);
t('-5946.90816', '-5946.90816', 5, 3);
t('608475', '608475', 6, 6);
t('-249815496353142605063083339706423770452529255711064841247978.1649', '-249815496353142605063083339706423770452529255711064841247978.16482575714251625720191747855256', 4, 3);
t('-8757939868931375459275247990933877309', '-8757939868931375459275247990933877309', 37, 5);
t('556228688742576287254121716253667920283844645854057755303259369', '556228688742576287254121716253667920283844645854057755303259369', 25, 3);
t('0', '0.00000000000000000000000000000000000000000000000029171651270270187897342247995644546232788426', 35, 3);
t('-0.0000058979376152458865088785307705', '-0.000005897937615245886508878530770431196412050562641578155968', 34, 0);
t('-0.00000000000000847145658', '-0.00000000000000847145657888758222743159237', 23, 3);
t('-6049825281564367887763596943301191584240212075976455', '-6049825281564367887763596943301191584240212075976455', 53, 0);
t('-64680661822322715719008107701612.741312367131318202976964422', '-64680661822322715719008107701612.74131236713131820297696442216284615573809', 27, 4);
t('-0', '-0.0000000000000000000000000000000000048810387700772580768508931440796984745771392', 29, 2);
t('232730083859746141163.7653402888578932348762190816502', '232730083859746141163.76534028885789323487621908165018267559238917447610653431235463768839108', 31, 5);
t('-499311204526771278437755030091270601.471802335', '-499311204526771278437755030091270601.47180233568698638607829334564', 9, 2);
t('-4793558721695298336734196955569628362250.1', '-4793558721695298336734196955569628362250.107513868618556605590137359591047843592593', 1, 6);
t('0.0000000000000000000000000000000000000622', '0.000000000000000000000000000000000000062176566496', 40, 5);
t('-393323198834362857317921391989917230.1575124832953752419421908305674188204', '-393323198834362857317921391989917230.15751248329537524194219083056741882044261538788798', 37, 5);
t('-0', '-0.000000000000000169092170076859363', 3, 5);
t('0.00085774283834918184933525579624189945402764', '0.0008577428383491818493352557962418994540276420616048890965876345513', 44, 4);
t('-127706837731025454069338274697755478243.226555768723254468591', '-127706837731025454069338274697755478243.226555768723254468591', 21, 4);
t('0.0000000000000000000000000000002', '0.00000000000000000000000000000024', 31, 6);
t('0', '0.0000000000000000006', 0, 4);
t('0.000000000000000000000007810237984104', '0.00000000000000000000000781023798410401506609033130277607174', 36, 6);
t('-0.0000000000000000000000000000000000000000000003', '-0.00000000000000000000000000000000000000000000030032464295099044566372323', 46, 1);
t('-685966223751248103958158215191994961086468451812432', '-685966223751248103958158215191994961086468451812432', 15, 6);
t('-342139733926317660019.326340161146875487297', '-342139733926317660019.326340161146875487297346019153178', 21, 6);
t('0', '0.000000000000000000000000000000000000000000901836202', 15, 4);
t('54703159147681578.1514852895273075959730711237955491690133829927977209580124', '54703159147681578.1514852895273075959730711237955491690133829927977209580124', 59, 0);
t('-460718430436988680547605508933197195738591668941440213118174196', '-460718430436988680547605508933197195738591668941440213118174196', 16, 6);
t('70597943458486911871858911963104830835210711517857117431432573585719054629372', '70597943458486911871858911963104830835210711517857117431432573585719054629372', 17, 3);
t('0', '0.0000000000000000000000005', 17, 1);
t('612277653819449429818059108521923195679275819340316389136081740197236376194', '612277653819449429818059108521923195679275819340316389136081740197236376194', 24, 6);
t('0', '0.000004077002116450599035175933786605407147118579202271612670066923117668943811493201471493894', 0, 3);
t('0', '0.0000000000000000454362126792715044166595091', 4, 5);
t('-0.00000000000000000000000247815', '-0.00000000000000000000000247815', 29, 2);
t('-0.000000000000000000000000000000039578053693', '-0.000000000000000000000000000000039578053693375996216932325600263217353654', 42, 4);
t('-232816283401672701377791127757043050155711815150567236808118951', '-232816283401672701377791127757043050155711815150567236808118951', 5, 2);
t('-29071348593675752783607764808066026', '-29071348593675752783607764808066026', 0, 3);
t('-0', '-0.0000000000000000000000000000001261801374206123908708248209346534624420321535319795165638569', 3, 5);
t('-400979013779505784551704647545324555644743917317817725', '-400979013779505784551704647545324555644743917317817725', 51, 0);
t('-707984518604562445981560648691697348187535181109991331112833004096934116229906958', '-707984518604562445981560648691697348187535181109991331112833004096934116229906958', 33, 3);
t('-0.00000000000000000000054943542078511748325889425', '-0.00000000000000000000054943542078511748325889425029425118', 48, 2);
t('0.000000000000000000000000000001', '0.0000000000000000000000000000000004', 30, 2);
t('8361324754302.257', '8361324754302.25608823898722021345099998761427662952277448263515002938433228636937277798222125', 3, 2);
t('47845474280015515238795364952786480611238289992139357357828.2393536', '47845474280015515238795364952786480611238289992139357357828.23935359', 7, 2);
t('2549907485257905040787802731022172814.032473410309278713663931353982863019132463', '2549907485257905040787802731022172814.03247341030927871366393135398286301913246263649610180999011', 42, 4);
t('7245563391265598645357861460253613932139592382610560614764364520097782949512752649', '7245563391265598645357861460253613932139592382610560614764364520097782949512752649', 40, 1);
t('80140230840302995211398777354070268652682793260175436489292', '80140230840302995211398777354070268652682793260175436489292', 35, 5);
t('-6237457908203764779831412120415113057397781437576879126960196359736451276', '-6237457908203764779831412120415113057397781437576879126960196359736451276', 46, 3);
t('-64022435787355811014521281511793708435812347405139910972682589', '-64022435787355811014521281511793708435812347405139910972682589', 59, 4);
t('23773726397.29160222442891928943538179152516815326677387048397317891529', '23773726397.291602224428919289435381791525168153266773870483973178915287792', 59, 2);
t('-0.0000000000000000009191736362201691567821986127083610325635', '-0.00000000000000000091917363622016915678219861270836103256344707473557037101545788367584278310776658', 58, 3);
t('576493832674677623548573635478304255.82263895978273', '576493832674677623548573635478304255.82263895978273', 14, 5);
t('0.00000000001', '0.00000000000000000000000000000000000000000000000007822968340296738406', 11, 2);
t('-0', '-0.00000000000000000000000000000000000000000000000803017739', 16, 2);
t('-76782672919180281245123823777032511965124724736456274885479622075418722', '-76782672919180281245123823777032511965124724736456274885479622075418722', 48, 4);
t('4455851923984827076883518360355220330356', '4455851923984827076883518360355220330356', 36, 6);
t('6861599706553109843427643365400432566541688718985576240352998201999416183743', '6861599706553109843427643365400432566541688718985576240352998201999416183743', 2, 2);
t('0', '0.0000083135366316053183734543904737952651532784316140061929170739473518406297062533554026617147464', 0, 1);
t('72361127388902796012114362477322144735533135802605580980837229637633107.0925818254603', '72361127388902796012114362477322144735533135802605580980837229637633107.09258182546029609579105130429', 13, 5);
t('-273219046129778472266.058485499109338596573075', '-273219046129778472266.0584854991093385965730749815531346353045049027336176088162559', 24, 4);
t('-0.00000000000007280978660680040221854732703892674800762227646', '-0.00000000000007280978660680040221854732703892674800762227646226836240552990665555', 59, 5);
t('6276464097096605785329824864148.527049815380996985914', '6276464097096605785329824864148.52704981538099698591393138250952524233217779', 21, 0);
t('-597198', '-597197.628834953506966767991553710700934413500204012426446876175175114500037146677042239668', 0, 0);
t('-433359038877962603713455049783', '-433359038877962603713455049783', 30, 0);
t('0.0000000000000000000000000000000006381735336173415547900207', '0.0000000000000000000000000000000006381735336173415547900206847223271181528556195', 58, 0);
t('807050820.676699481791051456', '807050820.676699481791051455096629111775329549493444751897213743866128850061622892', 18, 2);
t('0.0000000000000000000000000000489752745584111598026871408099', '0.000000000000000000000000000048975274558411159802687140809907', 58, 3);
t('0', '0.0000000000000000000000000000000000000000000226067497099004331941912856', 36, 6);
t('39094507220356523575213839820749561678857032020620050894656716293.67495126324', '39094507220356523575213839820749561678857032020620050894656716293.67495126323710280607325675762434', 11, 2);
t('-22678769.817248435493696742588538', '-22678769.817248435493696742588538331241538369550386799148219117165563326051964281', 24, 4);
t('5767307789536064608781837241295188919', '5767307789536064608781837241295188919', 30, 0);
t('168139421336703751454723348941581.0989620502676347173183006762310303463068390391675336175', '168139421336703751454723348941581.0989620502676347173183006762310303463068390391675336175', 55, 6);
t('-88504154823150878334701258558002569539793415193610842759120001088201133334307983', '-88504154823150878334701258558002569539793415193610842759120001088201133334307983', 44, 4);
t('-329655464734888739743767364510089523323', '-329655464734888739743767364510089523323', 25, 1);
t('0.00000000000000000000084501920385200277918', '0.000000000000000000000845019203852002779189', 41, 1);
t('-5840123488663376216608124416421102623453621285401805153644515702191', '-5840123488663376216608124416421102623453621285401805153644515702191', 59, 3);
t('-0.00000062136', '-0.00000062135994705765807424168688040116009865960794', 13, 3);
t('-0.000000000000000000001', '-0.00000000000000000000000000000000000000001462340018509', 21, 0);
t('0.006', '0.0059936079684973012978514720463815026319867172', 4, 2);
t('526400924922583880463185416850358172941032433541198785132036360013561525242705246671523133061757', '526400924922583880463185416850358172941032433541198785132036360013561525242705246671523133061757', 38, 6);
t('-882873192309626516849737955750920016208815071464396145314', '-882873192309626516849737955750920016208815071464396145314', 46, 6);
t('-6758735221049379519.2572393', '-6758735221049379519.25723934716782621573177906', 7, 2);
t('-0.000000790786371520517683432954223230156393', '-0.00000079078637152051768343295422323015639290504929', 42, 4);
t('-0.00000000000000000000000000000000000091966', '-0.0000000000000000000000000000000000009196610338039484256720548095', 41, 6);
t('-0.00000000000541933780252974657673566396725809671507', '-0.0000000000054193378025297465767356639672580967150744942399', 50, 4);
t('-0.000000000000000000000583479626', '-0.000000000000000000000583479626800396501245049473177007318461587644875162633137088', 30, 2);
t('11604528953141243475', '11604528953141243475', 13, 3);
t('566807769866890.02801522720838416179840190775794257854696482', '566807769866890.02801522720838416179840190775794257854696482590456963092114076898', 44, 3);
t('-35620697798492911.0669248410687861643251268323797667576839159303711022', '-35620697798492911.066924841068786164325126832379766757683915930371102255700535220012496346147093317', 52, 1);
t('-0.0000000000000000000050597138398214172387021051', '-0.000000000000000000005059713839821417238702105087169671933387005', 46, 0);
t('-0.8174627036499993060703761337876311', '-0.81746270364999930607037613378763105641195817852303184573911882', 34, 4);
t('0.0000000000000000000016801618027332596946', '0.000000000000000000001680161802733259694523102897059933026814910108114561982575916856344241', 40, 2);
t('-0.0005550919624693963627417354876271038367574907', '-0.000555091962469396362741735487627103836757490736793688', 46, 6);
t('0.00000000000001', '0.0000000000000000005989657036', 14, 2);
t('26923162467831521466200388799932149017792464401239965995848900909703513553682', '26923162467831521466200388799932149017792464401239965995848900909703513553682', 59, 0);
t('0.000000000000034716604224301619113605162061332208', '0.0000000000000347166042243016191136051620613322078875442915881933', 48, 5);
t('4554587644116353728395891927482', '4554587644116353728395891927482', 4, 4);
t('83', '83', 1, 4);
t('-0.0000000000000000679512312597136188846870750884127001656543', '-0.0000000000000000679512312597136188846870750884127001656543162955358', 58, 5);
t('-0.000000000000000005843127017405787209162333', '-0.0000000000000000058431270174057872091623337743081992327769648', 42, 2);
t('698142412071442689875148052035405913655358215178078673989', '698142412071442689875148052035405913655358215178078673989', 31, 2);
t('-0.000000000000000000000000001', '-0.0000000000000000000000000000000000000009', 27, 3);
t('0', '0.000000000000000000000000000000000000000000000000086322062431379058693358', 36, 6);
t('-7097679626212584135194693334505819500.76271239784243114877303953752095973790591', '-7097679626212584135194693334505819500.7627123978424311487730395375209597379059174819443305631091738', 41, 1);
t('720941616590530465684319461159925340787620861616050215112729354513077297889437424470222725372.4341', '720941616590530465684319461159925340787620861616050215112729354513077297889437424470222725372.43418', 4, 1);
t('-8565045.0741813', '-8565045.07418120224', 7, 3);
t('7179182230007440380654240229988748528461622212340003478705', '7179182230007440380654240229988748528461622212340003478705', 16, 1);
t('128138852434106311723518159896099183377408757231649238006509175039', '128138852434106311723518159896099183377408757231649238006509175039', 51, 0);
t('0.0000000000000000000000000000000000071444116240971906475', '0.000000000000000000000000000000000007144411624097190647497044019271703768941206', 56, 5);
t('0', '0.00000000000000000000000000000000000000000000021714481944', 43, 6);
t('-0.0000000000000001', '-0.0000000000000000000000000034534834', 16, 0);
t('-0.0000000000000000000008286492885892336366506247591678062602', '-0.00000000000000000000082864928858923363665062475916780626021532507656936043414109352811732', 58, 1);
t('31161421229261423772494491055755169247634601491928', '31161421229261423772494491055755169247634601491928', 51, 3);
t('1748715317929813133410156549170209422179478560908330825848622104018934659066', '1748715317929813133410156549170209422179478560908330825848622104018934659066', 57, 4);
t('-554303811557294466.269761483473739646624314242607077', '-554303811557294466.269761483473739646624314242607077815435340758612837177421989342652', 33, 1);
t('-0.19004485', '-0.19004485473016995992614957080209680408919713640428488619', 8, 1);
t('0.000252525605711892', '0.000252525605711891731866212005527221984514215823140269482997380211714402276122070798053', 18, 6);
t('86245969707619', '86245969707619', 14, 3);
t('-31435925010862195008998682761', '-31435925010862195008998682761', 9, 3);
t('-7376.12482208', '-7376.124822087908447175101', 8, 2);
t('0.000080221434577125714125624728141606555230430450054', '0.0000802214345771257141256247281416065552304304500535613033078792598113626175', 51, 0);
t('-6050582615205191601389958119203059837835097590785064613410822037914417495686026661', '-6050582615205191601389958119203059837835097590785064613410822037914417495686026661', 31, 1);
t('0.00000000000000003455493043277403696896050418463562482', '0.0000000000000000345549304327740369689605041846356248273019036250593274409786087865531980510674', 53, 3);
t('-20967.65067808575', '-20967.6506780857520813447701235001803657407937', 11, 6);
t('568254966593770.553753276551449605949', '568254966593770.553753276551449605948238816764309803642928261672349658172008375162162314878680613', 21, 0);
t('-451.149170475956331479335', '-451.1491704759563314793340102771090380475440750267088321862964226523091325726805634622304958123379', 21, 3);
t('-0.00000000000000000000000089587927281631480799', '-0.00000000000000000000000089587927281631480798176250533957436898566513857011780218162097370714526', 44, 0);
t('0.00006', '0.00005989898942742447311513559', 6, 2);
t('0.00000000000000000000000000000000000084666165975', '0.000000000000000000000000000000000000846661659751645', 47, 6);
t('-274912.8896024699', '-274912.8896024699118787839924993246206752520896053416203239133353705', 10, 1);
t('2884607226068313798651836226110538860137007975185098848', '2884607226068313798651836226110538860137007975185098848', 55, 6);
t('-0.00000000000000000002773912168', '-0.000000000000000000027739121678637743521714908420713523555500095414277237781740952561559672', 29, 3);
t('-2651358523359639', '-2651358523359639', 16, 4);
t('-4813276596516131663456402092.38944176', '-4813276596516131663456402092.3894417517916213734867', 8, 3);
t('-0.000000000000000000000000000000000000112895859', '-0.000000000000000000000000000000000000112895858119340820153717620708673416', 45, 0);
t('-0.0000000000000000021', '-0.0000000000000000020224974226159732231298241899365279396237510862449464734463589', 19, 3);
t('-7589382547973376572325815568183010749314649708', '-7589382547973376572325815568183010749314649708', 33, 5);
t('842229243093860852173.05443961588175098377444082861489172139756969332835', '842229243093860852173.0544396158817509837744408286148917213975696933283408713841831638764', 50, 0);
t('-699708233495.712278374225898965891885496', '-699708233495.71227837422589896589188549642075052667001859282382939797996992686357419809583', 27, 4);
t('-0.00000000071616892037859054', '-0.000000000716168920378590537721800581109521242491374877', 26, 0);
t('3951438403.277181863849692687044689923289027507211228628773736', '3951438403.2771818638496926870446899232890275072112286287737359542096', 51, 2);
t('109559.01297171197941271991562118124015322', '109559.012971711979412719915621181240153223610175595763848035079898263530366', 35, 3);
t('-0.00000000000000000000000000000000000000000000489005761683947', '-0.00000000000000000000000000000000000000000000489005761683946256390055271579820502403', 59, 3);
t('-0.00158', '-0.00158276409341184629828973465939702170102740363504722102864514069935682480434491', 5, 2);
t('-2625562538887919963240549817430379735187837775384', '-2625562538887919963240549817430379735187837775384', 44, 0);
t('0', '0.00000000000000000000002', 9, 1);
t('6744808.28630410992583043657159413157574982400492', '6744808.28630410992583043657159413157574982400491999838773235902794700459508120619939892', 42, 6);
t('0.000000000000000009', '0.000000000000000009', 18, 3);
t('6067881766683695479556751950119377724336039886809300136812181462', '6067881766683695479556751950119377724336039886809300136812181462', 31, 1);
t('0.000000000000000000000000000000000000000077241022793', '0.0000000000000000000000000000000000000000772410227935606591033087412064412570098277', 51, 1);
t('743268323094543466714.5656060177009296968524561226948074051004264', '743268323094543466714.565606017700929696852456122694807405100426400624651576046667459841457817767865', 43, 3);
t('-596135', '-596135', 3, 2);
t('0.07662404229928167815820747802086592943344134084819', '0.0766240422992816781582074780208659294334413408481864862625859275536716954542357278357044523255', 50, 4);
t('-0.000000000000000000000000000885256', '-0.000000000000000000000000000885255222637729340070545710310579917592457286140653', 33, 0);
t('55893020145100569857309952693924435456669213.356281068124371401302229274073839082240544043386519', '55893020145100569857309952693924435456669213.356281068124371401302229274073839082240544043386519', 51, 0);
t('0.000000000044398802543439239843437872656117', '0.000000000044398802543439239843437872656117345711426288269229', 42, 1);
t('0.000000000000000000000000000026311845042475573561274888459', '0.00000000000000000000000000002631184504247557356127488845876295156781061349824020867304', 57, 6);
t('-127546673151161350153045221729711', '-127546673151161350153045221729711', 2, 5);
t('0.0000000000000000000000846081', '0.00000000000000000000008460817346743347251678412215465432867047065857', 28, 3);
t('-51296363216658187515760473402291', '-51296363216658187515760473402291', 27, 4);
t('-8623967090632480689370959269411792112227821530531202541003992985', '-8623967090632480689370959269411792112227821530531202541003992985', 54, 5);
t('-966322003490784535731979767036707880939452169502093813823674817588484', '-966322003490784535731979767036707880939452169502093813823674817588484', 56, 5);
t('-272472379898107893040761485379027824396136886208', '-272472379898107893040761485379027824396136886208', 40, 1);
t('0.000000000000000000007578294653267877535740172858883482', '0.00000000000000000000757829465326787753574017285888348202441720573692830214583542806201', 55, 6);
t('25958781094763030494523126276550672249453141421083859868561356127876297714106602172585', '25958781094763030494523126276550672249453141421083859868561356127876297714106602172585', 29, 5);
t('0.00000000000000000000000000000000000002', '0.000000000000000000000000000000000000015806075051053843417566111132263641553843698646164', 38, 5);
t('-73099329416955017257739991488405608089647281115099586', '-73099329416955017257739991488405608089647281115099586', 21, 6);
t('-88307320.90319141093816288808957670297463', '-88307320.903191410938162888089576702974638474154077235587259266824247410860533478169707304792818', 32, 2);
t('-35236814557361445958969411965214520.30399877405421', '-35236814557361445958969411965214520.303998774054210302477326477', 14, 2);
t('-2908087206403224796868158372851057.39782067611', '-2908087206403224796868158372851057.3978206761117082535006786132666114643644421715709235528929678', 11, 4);
t('-19581413994383784948718328954653', '-19581413994383784948718328954653', 28, 1);
t('0.00000000000000000000000000004', '0.000000000000000000000000000040608230569366379665209245709785291404206510745612419401142658', 29, 3);
t('-0.906238977426875501362745', '-0.9062389774268755013627459831223515271076867650054627805581400941104277662892230888597201', 24, 2);
t('0', '0.000000000000000000000025517761823978244291048210421988594612225022695964910425529', 21, 1);
t('663336.45734367931832199866', '663336.4573436793183219986595282312647796998714487327022132545955984591825466144183', 20, 4);
t('-461221276.52047063868261544207237644195170184', '-461221276.5204706386826154420723764419517018397461911607', 36, 4);
t('92664692270788697481952993240101', '92664692270788697481952993240101', 9, 1);
t('0.00000000000001', '0.0000000000000000417218487798321067688965201563233239322412080713783058725771499175637', 14, 0);
t('-0.00000000000000291161', '-0.0000000000000029116100944057582762735577555', 21, 6);
t('3593092835933826522602826541522473977510499517734180584911059518', '3593092835933826522602826541522473977510499517734180584911059518', 39, 2);
t('0.00000000000240671872382434259', '0.00000000000240671872382434258731759266816542514881094906467645247797685306920193421', 29, 6);
t('98445608185462908936594271820438358882244286228', '98445608185462908936594271820438358882244286228', 43, 4);
t('-38275693035627727048820160757435988950513161', '-38275693035627727048820160757435988950513161', 28, 2);
t('0.000000000000000007838540274247171557849126', '0.000000000000000007838540274247171557849125417291807341828802631329086161031903106930206518314803525', 42, 0);
t('0', '0.0000000000000000000000000000000000000008760161376', 38, 6);
t('-274462946120897177140732986024361620867165740004629583369799434.752624497847', '-274462946120897177140732986024361620867165740004629583369799434.7526244978472107528071824755321251', 12, 1);
t('805407519521180265118391229', '805407519521180265118391229', 27, 0);
t('4837.60752412303502514', '4837.60752412303502513085517977565448616961234363618524491896285197928079211821305450283483280681236', 17, 0);
t('19446.966116400627008657626752077217581388920002', '19446.966116400627008657626752077217581388920001650492489914443643730475', 42, 6);
t('259711114990641', '259711114990641', 1, 3);
t('-0.0000000001', '-0.0000000000000000002', 10, 0);
t('80565580.149080509196072203611545842035798415', '80565580.1490805091960722036115458420357984148292066084650845696757793247885015079193577022206528568', 36, 5);
t('0.000000005126609951384222369644011060208031', '0.00000000512660995138422236964401106020803193692417523731220078957765716642', 42, 3);
t('1758006742538130240388703498480688686072955030356.7524172233646685', '1758006742538130240388703498480688686072955030356.75241722336466855', 16, 1);
t('-128086989690.52297791537155595882257011356310571016034760745375196584546', '-128086989690.5229779153715559588225701135631057101603476074537519658454607884909539951', 59, 2);
t('-361166416734639117275346911473316661252428418964862.401', '-361166416734639117275346911473316661252428418964862.400974469693342990746', 4, 5);
t('71633752430127836728495483808.07484204148983764432608854793881189', '71633752430127836728495483808.074842041489837644326088547938811892934755621628332271860178432369', 35, 4);
t('5744453717566208360238616812981884481035389801', '5744453717566208360238616812981884481035389801', 46, 1);
t('2988347090930431122495200201632971168964831173901728', '2988347090930431122495200201632971168964831173901728', 31, 0);
t('2320482568655945754105081468655336561175857', '2320482568655945754105081468655336561175857', 13, 6);
t('0.0000000000000000000000381190632343589292', '0.0000000000000000000000381190632343589291525554226892790057468635150617798724', 40, 6);
t('-815303438910393610000000000000000000000000000', '-815303438910393610000000000000000000000000000.5', 0, 7);
t('48079804879135055337410501154945563557501499846191760613365317572636043210233866737200001', '48079804879135055337410501154945563557501499846191760613365317572636043210233866737200000.5', 0, 7);
t('775141321458031580151353003447938403271713528287267233801607476638641728594600000000001', '775141321458031580151353003447938403271713528287267233801607476638641728594600000000000.5', 0, 7);
t('-3246099003639468003580507000000000000000000000000000000000000000000000000000000000000000000000000000', '-3246099003639468003580507000000000000000000000000000000000000000000000000000000000000000000000000000.5', 0, 7);
t('616052744557652711', '616052744557652710.5', 0, 7);
t('-47298707260000000000000000000000000000000', '-47298707260000000000000000000000000000000.5', 0, 7);
t('431370739475777039213491701837719630211035950221951900000000000000000001', '431370739475777039213491701837719630211035950221951900000000000000000000.5', 0, 7);
t('54683100000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', '54683100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.5', 0, 7);
t('672783487870821678831521822264427999625400000000000000000000000000000000000000001', '672783487870821678831521822264427999625400000000000000000000000000000000000000000.5', 0, 7);
t('85750000000000000000000000000000000000000001', '85750000000000000000000000000000000000000000.5', 0, 7);
t('-357280726879877087440504485199000000000000000000000', '-357280726879877087440504485199000000000000000000000.5', 0, 7);
t('-4341299477000000000000000000000', '-4341299477000000000000000000000.5', 0, 7);
t('31902000001', '31902000000.5', 0, 7);
t('333458122140379389691720067000000000000000000000000000000000000000000001', '333458122140379389691720067000000000000000000000000000000000000000000000.5', 0, 7);
t('-459839025400000000000000000000', '-459839025400000000000000000000.5', 0, 7);
t('-82390000000000', '-82390000000000.5', 0, 7);
t('76701', '76700.5', 0, 7);
t('190430490057932227000000000000000000000000000000000000001', '190430490057932227000000000000000000000000000000000000000.5', 0, 7);
t('60159411740605592996051862591038032930184607684088677320000000000000000000000001', '60159411740605592996051862591038032930184607684088677320000000000000000000000000.5', 0, 7);
t('-2234900000', '-2234900000.5', 0, 7);
t('56189665877093832601689082910000000000000000000000000000000000000001', '56189665877093832601689082910000000000000000000000000000000000000000.5', 0, 7);
t('2320000000000000000000000000001', '2320000000000000000000000000000.5', 0, 7);
t('-6305981611547961162835048322675738149574948489012480000000000000', '-6305981611547961162835048322675738149574948489012480000000000000.5', 0, 7);
t('7135722984978446900000000000000000000000000000000000001', '7135722984978446900000000000000000000000000000000000000.5', 0, 7);
t('7739620000000000000000000000000000000000000000000000001', '7739620000000000000000000000000000000000000000000000000.5', 0, 7);
t('-7310071091565097458378697755962864041334940666867342517847595229165394387202247229680000000', '-7310071091565097458378697755962864041334940666867342517847595229165394387202247229680000000.5', 0, 7);
t('5138337172269533148524367880141880518489245800000000000001', '5138337172269533148524367880141880518489245800000000000000.5', 0, 7);
t('-6000', '-6000.5', 0, 7);
t('463879090754017750000000000000001', '463879090754017750000000000000000.5', 0, 7);
t('-629850000000000000000', '-629850000000000000000.5', 0, 7);
t('-205429044500000000000000000000', '-205429044500000000000000000000.5', 0, 7);
t('-5416257015618874559905147873000000000000000000000000000000000000000000000000', '-5416257015618874559905147873000000000000000000000000000000000000000000000000.5', 0, 7);
t('623364421289248201317000000000000001', '623364421289248201317000000000000000.5', 0, 7);
t('911141136528601', '911141136528600.5', 0, 7);
t('-276055672501612195718314543393745315761189100000', '-276055672501612195718314543393745315761189100000.5', 0, 7);
t('66201703687996196493948073895661219741.79732939050299983848272445', '66201703687996196493948073895661219741.79732939050299983848272444531659415942809827190951', 26, 8);
t('-432784391834045276975262545157922', '-432784391834045276975262545157922', 28, 8);
t('1149345737914160007440457748332143986414.9571', '1149345737914160007440457748332143986414.957136799115537152433594986979', 4, 8);
t('-8955086490844848921210649185442547', '-8955086490844848921210649185442547', 35, 8);
t('425088038661656538743278817856878424164093767.85670041722429249440202331857043', '425088038661656538743278817856878424164093767.85670041722429249440202331857043013807', 33, 8);
t('-309644694334054373034963302293381012433965117503313464512444644', '-309644694334054373034963302293381012433965117503313464512444644', 15, 8);
t('-6113258580590430007589739873373442564851315606055053637944', '-6113258580590430007589739873373442564851315606055053637944', 20, 8);
t('-79578809228411034521778967729244470830365009197702327546767865195836773388369068481948969.900741', '-79578809228411034521778967729244470830365009197702327546767865195836773388369068481948969.9007405268', 6, 8);
t('-98635952437161220.96618', '-98635952437161220.9661782723695091452045447927505345126085', 5, 8);
t('5306244228965561737.62447596491901907069113187489713', '5306244228965561737.62447596491901907069113187489712907837802453330192181391370636667897993', 32, 8);
t('881494696226260293271264.36459456081728760273917638738994049272140009', '881494696226260293271264.36459456081728760273917638738994049272140008956721', 45, 8);
t('0', '0.0000000000000000398975254', 1, 8);
t('-2966907742563204474300609285105763571411556718257633358168823625207636310562902929129639632', '-2966907742563204474300609285105763571411556718257633358168823625207636310562902929129639632', 59, 8);
t('4815226942078558754202763870371111530259178454324372013168459692655444158537', '4815226942078558754202763870371111530259178454324372013168459692655444158537', 58, 8);
t('89735736519038061687.396102956878866121243318078603705593756032576774631567136', '89735736519038061687.396102956878866121243318078603705593756032576774631567136', 57, 8);
t('-5139206863826452924558709317549576110217185', '-5139206863826452924558709317549576110217185', 10, 8);
t('410799450059.233711597011245238081176283367945619000645947401973880735', '410799450059.23371159701124523808117628336794561900064594740197388073499637579092523992206', 59, 8);
t('-1861173217597843873200339700375118033056165470698896905908777053211294087744', '-1861173217597843873200339700375118033056165470698896905908777053211294087744', 38, 8);
t('-0', '-0.00000000000000006595', 11, 8);
t('-5407783849362963393803124142731051275240080145012', '-5407783849362963393803124142731051275240080145012', 20, 8);
t('-34168517091385789116719661427034183841563988149', '-34168517091385789116719661427034183841563988149', 17, 8);
t('5795445846', '5795445846', 2, 8);
t('8225834668202811700000', '8225834668202811700000.5', 0, 8);
t('-67268029621398311238261431331851556661886545942854113916050734581000000000001', '-67268029621398311238261431331851556661886545942854113916050734581000000000000.5', 0, 8);
t('4100000', '4100000.5', 0, 8);
t('694900000000000', '694900000000000.5', 0, 8);
t('-2668752017792840000000000000000000000000000000000000000000000000000000000001', '-2668752017792840000000000000000000000000000000000000000000000000000000000000.5', 0, 8);
t('5138303265393258323808903836559900000000000000000', '5138303265393258323808903836559900000000000000000.5', 0, 8);
t('-61599472977109463564534878506157000000000000000000000000000000001', '-61599472977109463564534878506157000000000000000000000000000000000.5', 0, 8);
t('-706579187032566119663804136174620000000000000000001', '-706579187032566119663804136174620000000000000000000.5', 0, 8);
t('10', '10.5', 0, 8);
t('903942469098308100136613765218227935820271584538277900367517300000000000000000', '903942469098308100136613765218227935820271584538277900367517300000000000000000.5', 0, 8);
t('7259090494485579718152684060350290000000000000000000000000000000000000000000000000000000000', '7259090494485579718152684060350290000000000000000000000000000000000000000000000000000000000.5', 0, 8);
t('50', '50.5', 0, 8);
t('-336051', '-336050.5', 0, 8);
t('12.345', '12.345');
t('12', '12.345', 0);
tx(function () {new Decimal('12.345').toDP('2')}, ".toDP('2')");
tx(function () {new Decimal('12.345').toDP(new Decimal('2'))}, ".toDP(new Decimal('2'))");
tx(function () {new Decimal('12.345').toDP(null)}, ".toDP(null)");
tx(function () {new Decimal('12.345').toDP(NaN)}, ".toDP(NaN)");
tx(function () {new Decimal('12.345').toDP('NaN')}, ".toDP('NaN')");
tx(function () {new Decimal('12.345').toDP([])}, ".toDP([])");
tx(function () {new Decimal('12.345').toDP({})}, ".toDP({})");
tx(function () {new Decimal('12.345').toDP('')}, ".toDP('')");
tx(function () {new Decimal('12.345').toDP(' ')}, ".toDP(' ')");
tx(function () {new Decimal('12.345').toDP('hello')}, ".toDP('hello')");
tx(function () {new Decimal('12.345').toDP('\t')}, ".toDP('\t')");
tx(function () {new Decimal('12.345').toDP(new Date)}, ".toDP(new Date)");
tx(function () {new Decimal('12.345').toDP(new RegExp)}, ".toDP(new RegExp)");
tx(function () {new Decimal('12.345').toDP(7.5)}, ".toDP(7.5)");
tx(function () {new Decimal('12.345').toDP('1.1e1')}, ".toDP('1.1e1')");
tx(function () {new Decimal('12.345').toDP('-1')}, ".toDP('-1')");
tx(function () {new Decimal('12.345').toDP(-23)}, ".toDP(-23)");
tx(function () {new Decimal('12.345').toDP(1e9 + 1)}, ".toDP(1e9 + 1)");
tx(function () {new Decimal('12.345').toDP(1e9 + 0.1)}, ".toDP(1e9 + 1)");
tx(function () {new Decimal('12.345').toDP('-0.01')}, ".toDP('-0.01')");
tx(function () {new Decimal('12.345').toDP('-1e-1')}, ".toDP('-1e-1')");
tx(function () {new Decimal('12.345').toDP(Infinity)}, ".toDP(Infinity)");
tx(function () {new Decimal('12.345').toDP('-Infinity')}, ".toDP('-Infinity')");
tx(function () {new Decimal('12.345').toDP(1, '2')}, ".toDP(1, '2')");
tx(function () {new Decimal('12.345').toDP(1, new Decimal('2'))}, ".toDP(1, new Decimal('2'))");
tx(function () {new Decimal('12.345').toDP(1, null)}, ".toDP(1, null)");
tx(function () {new Decimal('12.345').toDP(1, NaN)}, ".toDP(1, NaN)");
tx(function () {new Decimal('12.345').toDP(1, 'NaN')}, ".toDP(1, 'NaN')");
tx(function () {new Decimal('12.345').toDP(1, [])}, ".toDP(1, [])");
tx(function () {new Decimal('12.345').toDP(1, {})}, ".toDP(1, {})");
tx(function () {new Decimal('12.345').toDP(1, '')}, ".toDP(1, '')");
tx(function () {new Decimal('12.345').toDP(1, ' ')}, ".toDP(1, ' ')");
tx(function () {new Decimal('12.345').toDP(1, 'hello')}, ".toDP(1, 'hello')");
tx(function () {new Decimal('12.345').toDP(1, '\t')}, ".toDP(1, '\t')");
tx(function () {new Decimal('12.345').toDP(1, new Date)}, ".toDP(1, new Date)");
tx(function () {new Decimal('12.345').toDP(1, new RegExp)}, ".toDP(1, new RegExp)");
tx(function () {new Decimal('12.345').toDP(1, 7.5)}, ".toDP(1, 7.5)");
tx(function () {new Decimal('12.345').toDP(1, '1.1e1')}, ".toDP(1, '1.1e1')");
tx(function () {new Decimal('12.345').toDP(1, '-1')}, ".toDP(1, '-1')");
tx(function () {new Decimal('12.345').toDP(1, -23)}, ".toDP(1, -23)");
tx(function () {new Decimal('12.345').toDP(1, 9)}, ".toDP(1, 9)");
tx(function () {new Decimal('12.345').toDP(1, 8.001)}, ".toDP(1, 8.001)");
tx(function () {new Decimal('12.345').toDP(1, '-0.01')}, ".toDP(1, '-0.01')");
tx(function () {new Decimal('12.345').toDP(1, '-1e-1')}, ".toDP(1, '-1e-1')");
tx(function () {new Decimal('12.345').toDP(1, Infinity)}, ".toDP(1, Infinity)");
tx(function () {new Decimal('12.345').toDP(1, '-Infinity')}, ".toDP(1, '-Infinity')");
T.stop();
})();

View File

@ -0,0 +1,558 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toExponential');
function t(expected, n, dp) {
T.assertEqual(expected, new Decimal(n).toExponential(dp));
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('1e+0', 1);
t('1.1e+1', 11);
t('1.12e+2', 112);
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);
t('1.1e-1', 0.11);
t('1.12e-1', 0.112);
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);
t('-1.1e+1', -11);
t('-1.12e+2', -112);
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);
t('-1.1e-1', -0.11);
t('-1.12e-1', -0.112);
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);
t('NaN', -NaN, 2);
t('Infinity', Infinity);
t('Infinity', Infinity, 10);
t('-Infinity', -Infinity, 0);
t('-Infinity', -Infinity, 1);
t('0e+0', 0);
t('0e+0', -0);
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);
t('-1.12356e-4', -0.000112356);
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');
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);
Decimal.rounding = 1;
t('0e+0', '-0.0E-0');
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);
Decimal.rounding = 2;
t('0e+0', '0E0000000000');
t('0e+0', '-0E01');
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);
Decimal.rounding = 3;
t('-9.99999999000000009e+8', '-999999999.000000009e-0');
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);
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('-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('-8.638990742871e-16', '-0.0000000000000008638990742870608', 12);
t('-1.57817750020560815944470062e+12', '-1578177500205.60815944470062002898187', 26);
t('-3.6558384593093900422637e-27', '-0.00000000000000000000000000365583845930939004226367940618', 22);
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('-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);
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);
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.23e+2', '123');
t('1e+2', '123', 0);
t('1e+2', '123', -0);
tx(function () {new Decimal('1.23').toExponential('3')}, "('1.23').toExponential('3')");
tx(function () {new Decimal('1.23').toExponential(new Decimal('3'))}, "('1.23').toExponential(new Decimal('3'))");
tx(function () {new Decimal('1.23').toExponential(null)}, "('1.23').toExponential(null)");
tx(function () {new Decimal('1.23').toExponential(NaN)}, "('1.23').toExponential(NaN)");
tx(function () {new Decimal('1.23').toExponential('NaN')}, "('1.23').toExponential('NaN')");
tx(function () {new Decimal('1.23').toExponential([])}, "('1.23').toExponential([])");
tx(function () {new Decimal('1.23').toExponential({})}, "('1.23').toExponential({})");
tx(function () {new Decimal('1.23').toExponential('')}, "('1.23').toExponential('')");
tx(function () {new Decimal('1.23').toExponential(' ')}, "('1.23').toExponential(' ')");
tx(function () {new Decimal('1.23').toExponential('hello')}, "('1.23').toExponential('hello')");
tx(function () {new Decimal('1.23').toExponential('\t')}, "('1.23').toExponential('\t')");
tx(function () {new Decimal('1.23').toExponential(new Date)}, "('1.23').toExponential(new Date)");
tx(function () {new Decimal('1.23').toExponential(new RegExp)}, "('1.23').toExponential(new RegExp)");
tx(function () {new Decimal('1.23').toExponential(2.01)}, "('1.23').toExponential(2.01)");
tx(function () {new Decimal('1.23').toExponential(10.5)}, "('1.23').toExponential(10.5)");
tx(function () {new Decimal('1.23').toExponential('1.1e1')}, "('1.23').toExponential('1.1e1')");
tx(function () {new Decimal('1.23').toExponential(true)}, "('1.23').toExponential(true)");
tx(function () {new Decimal('1.23').toExponential(false)}, "('1.23').toExponential(false)");
tx(function () {new Decimal('1.23').toExponential(function (){})}, "('1.23').toExponential(function (){})");
tx(function () {new Decimal(1.23).toExponential('-1')}, ".toExponential('-1')");
tx(function () {new Decimal(1.23).toExponential(-23)}, ".toExponential(-23)");
tx(function () {new Decimal(1.23).toExponential(1e9 + 1)}, ".toExponential(1e9 + 1)");
tx(function () {new Decimal(1.23).toExponential(-0.01)}, ".toExponential(-0.01)");
tx(function () {new Decimal(1.23).toExponential('-1e-1')}, ".toExponential('-1e-1')");
tx(function () {new Decimal(1.23).toExponential(Infinity)}, ".toExponential(Infinity)");
tx(function () {new Decimal(1.23).toExponential('-Infinity')}, ".toExponential('-Infinity')");
tx(function () {new Decimal('1.23').toExponential(1, '3')}, "('1.23').toExponential(1, '3')");
tx(function () {new Decimal('1.23').toExponential(1, new Decimal('3'))}, "('1.23').toExponential(1, new Decimal('3'))");
tx(function () {new Decimal('1.23').toExponential(1, null)}, "('1.23').toExponential(1, null)");
tx(function () {new Decimal('1.23').toExponential(1, NaN)}, "('1.23').toExponential(1, NaN)");
tx(function () {new Decimal('1.23').toExponential(1, 'NaN')}, "('1.23').toExponential(1, 'NaN')");
tx(function () {new Decimal('1.23').toExponential(1, [])}, "('1.23').toExponential(1, [])");
tx(function () {new Decimal('1.23').toExponential(1, {})}, "('1.23').toExponential(1, {})");
tx(function () {new Decimal('1.23').toExponential(1, '')}, "('1.23').toExponential(1, '')");
tx(function () {new Decimal('1.23').toExponential(1, ' ')}, "('1.23').toExponential(1, ' ')");
tx(function () {new Decimal('1.23').toExponential(1, 'hello')}, "('1.23').toExponential(1, 'hello')");
tx(function () {new Decimal('1.23').toExponential(1, '\t')}, "('1.23').toExponential(1, '\t')");
tx(function () {new Decimal('1.23').toExponential(1, new Date)}, "('1.23').toExponential(1, new Date)");
tx(function () {new Decimal('1.23').toExponential(1, new RegExp)}, "('1.23').toExponential(1, new RegExp)");
tx(function () {new Decimal('1.23').toExponential(1, 2.01)}, "('1.23').toExponential(1, 2.01)");
tx(function () {new Decimal('1.23').toExponential(1, 10.5)}, "('1.23').toExponential(1, 10.5)");
tx(function () {new Decimal('1.23').toExponential(1, '1.1e1')}, "('1.23').toExponential(1, '1.1e1')");
tx(function () {new Decimal('1.23').toExponential(1, true)}, "('1.23').toExponential(1, true)");
tx(function () {new Decimal('1.23').toExponential(1, false)}, "('1.23').toExponential(1, false)");
tx(function () {new Decimal('1.23').toExponential(1, function (){})}, "('1.23').toExponential(1, function (){})");
tx(function () {new Decimal(1.23).toExponential(1, '-1')}, ".toExponential(1, '-1')");
tx(function () {new Decimal(1.23).toExponential(1, -23)}, ".toExponential(1, -23)");
tx(function () {new Decimal(1.23).toExponential(1, 1e9 + 1)}, ".toExponential(1, 1e9 + 1)");
tx(function () {new Decimal(1.23).toExponential(1, -0.01)}, ".toExponential(1, -0.01)");
tx(function () {new Decimal(1.23).toExponential(1, '-1e-1')}, ".toExponential(1, '-1e-1')");
tx(function () {new Decimal(1.23).toExponential(1, Infinity)}, ".toExponential(1, Infinity)");
tx(function () {new Decimal(1.23).toExponential(1, '-Infinity')}, ".toExponential(1, '-Infinity')");
T.stop();
})();

579
test/modules/toFixed.js Normal file
View File

@ -0,0 +1,579 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toFixed');
function t(expected, n, dp) {
T.assertEqual(expected, new Decimal(n).toFixed(dp));
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
/*
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number/toFixed
JS: 2.26.toFixed(5) returns 2.26000
JS: -2.26.toFixed(5) returns -2.26
Decimal: new Decimal(-2.26).toFixed(5) returns -2.26000
*/
t('100.0', 99.9512986, 1);
t('10.0', 9.95036, 1);
t('1.0', 0.99, 1);
t('0.10', 0.09906, 2);
t('0.010', 0.0098034, 3);
t('NaN', NaN, 2);
t('Infinity', 1/0, 2);
t('-Infinity', -1/0, 2);
t('1111111111111111111111.00000000', '1111111111111111111111', 8);
t('0.1', 0.1, 1);
t('0.10', 0.1, 2);
t('0.100', 0.1, 3);
t('0.01', 0.01, 2);
t('0.010', 0.01, 3);
t('0.0100', 0.01, 4);
t('0.00', 0.001, 2);
t('0.001', 0.001, 3);
t('0.0010', 0.001, 4);
t('1.0000', 1, 4);
t('1.0', 1, 1);
t('1', 1, 0);
t('12', 12, 0);
t('1', 1.1, 0);
t('12', 12.1, 0);
t('1', 1.12, 0);
t('12', 12.12, 0);
t('0.0000006', 0.0000006, 7);
t('0.00000006', 0.00000006, 8);
t('0.000000060', 0.00000006, 9);
t('0.0000000600', 0.00000006, 10);
t('0', 0, 0);
t('0.0', 0, 1);
t('0.00', 0, 2);
t('-1111111111111111111111.00000000', '-1111111111111111111111', 8);
t('-0.1', -0.1, 1);
t('-0.10', -0.1, 2);
t('-0.100', -0.1, 3);
t('-0.01', -0.01, 2);
t('-0.010', -0.01, 3);
t('-0.0100', -0.01, 4);
t('-0.00', -0.001, 2);
t('-0.001', -0.001, 3);
t('-0.0010', -0.001, 4);
t('-1.0000', -1, 4);
t('-1.0', -1, 1);
t('-1', -1, 0);
t('-1', -1.1, 0);
t('-12', -12.1, 0);
t('-1', -1.12, 0);
t('-12', -12.12, 0);
t('-0.00000', -0.0000006, 5);
t('-0.0000006', -0.0000006, 7);
t('-0.00000006', -0.00000006, 8);
t('-0.000000060', -0.00000006, 9);
t('-0.0000000600', -0.00000006, 10);
t('0', 0, 0);
t('0', -0, 0);
t('0.0', -0, 1);
t('0.00', -0, 2);
t('0.00', '-0.0', 2);
t('0.00', '-0.0000', 2);
t('0.0000', -0, 4);
t('1000', 1000);
t('0.00001', 0.00001);
t('0.00001', 0.00001, 5);
t('0.00000000000000000010', '0.0000000000000000001', 20);
t('0.00001000000000000', 0.00001, 17);
t('1.00000000000000000', 1, 17);
t('1000000000000000128', '1000000000000000128');
t('100000000000000128.0', '100000000000000128', 1);
t('10000000000000128.00', '10000000000000128', 2);
t('10000000000000128.00000000000000000000', '10000000000000128', 20);
t('0', 0);
t('-42.000', -42, 3);
t('-1000000000000000128', '-1000000000000000128');
t('-0.00000000000000000010', '-0.0000000000000000001', 20);
t('0.12312312312312300000', '0.123123123123123', 20);
t('1', 0.5, 0);
t('-1', -0.5, 0);
t('1.3', 1.25, 1);
t('234.2041', 234.20405, 4);
t('234.2041', '234.204050000000000000000000000000006', 4);
Decimal.rounding = 0;
t('0.000001', '0.000001', 6);
t('6552606716539719300271040797809220.3', '6552606716539719300271040797809220.237838405', 1);
t('25605410.260045950231371', '25605410.260045950231370974066', 15);
t('-65593283.0000', '-65593283', 4);
t('-2238743875407788208860272230040067273281097722822075126.88000000000', '-2238743875407788208860272230040067273281097722822075126.88', 11);
t('-1714042659419404211.0000000', '-1714042659419404211', 7);
t('580861301.000', '580861301', 3);
t('-495746734.000', '-495746734', 3);
t('-909962202.00000', '-909962202', 5);
t('-6588.00', '-6588', 2);
t('-89235424125324.000000', '-89235424125324', 6);
t('-0.0001', '-0.0000000000177', 4);
t('-0.1', '-0.000000000000007', 1);
t('7086047552021418140460170703933026989776558656.864197000000000', '7086047552021418140460170703933026989776558656.864197', 15);
t('-0.0000000001', '-0.0000000000000000007707', 10);
t('6613833500.133407255728', '6613833500.133407255727325566781771', 12);
t('-0.60', '-0.6', 2);
t('-5800577761301861465745732694236894834.347199790459214393940', '-5800577761301861465745732694236894834.34719979045921439394', 21);
t('65495133621931312001260.90', '65495133621931312001260.89870016055223846451749943336585697', 2);
t('-0.0000001', '-0.0000000000021727264987520611266069544793244453321336', 7);
t('5138338134667513058267845351654.0073', '5138338134667513058267845351654.007282', 4);
t('-419591612781413402.1606094651083282', '-419591612781413402.16060946510832813452', 16);
t('-842984708.00000', '-842984708', 5);
t('6094679992788973717749530934167375519948195193196.00000000000', '6094679992788973717749530934167375519948195193196', 11);
t('3070926.00', '3070926', 2);
t('-0.0000000000000004274', '-0.00000000000000042733957907641417564294', 19);
t('-307434.0', '-307434', 1);
t('-7155930111672774753753.84501482871023', '-7155930111672774753753.845014828710226', 14);
t('-204638.0', '-204638', 1);
t('67354.81', '67354.801797', 2);
t('0.000042911675', '0.000042911674899533228107357062', 12);
t('-57865060735863.5903347110', '-57865060735863.590334711', 10);
t('-0.00889', '-0.0088857', 5);
t('655593535442553089245040020344044.000000000000', '655593535442553089245040020344044', 12);
t('-2077237944012133216588518213.9402', '-2077237944012133216588518213.9401561759783653376', 4);
t('3354.50', '3354.49314543', 2);
t('-0.00001', '-0.000000000000091204118667391473401958802734362777499449233', 5);
t('-2817626898661648124242602088971648489124280903.00000000000000000000000', '-2817626898661648124242602088971648489124280903', 23);
t('-0.1138', '-0.1137406345875745478881089475981775971743', 4);
t('372625.84', '372625.836933301', 2);
t('-0.0001', '-0.0000000000030295', 4);
Decimal.rounding = 1;
t('0.3', '0.3', 1);
t('-200258348374.3', '-200258348374.3595802551014614089785610548492885372322083789', 1);
t('-8996550690041157178188143247448286757711.5580857413', '-8996550690041157178188143247448286757711.55808574133329', 10);
t('-3172413669280032477.00', '-3172413669280032477', 2);
t('6547946357820.750067107731812021675', '6547946357820.750067107731812021675351468709784004', 21);
t('24188393190716631282750407915133817062572333100239.0000000000000000000', '24188393190716631282750407915133817062572333100239', 19);
t('539982361589798324286450574560330534901309503.82000000', '539982361589798324286450574560330534901309503.82', 8);
t('829898800701640360552652.0000', '829898800701640360552652', 4);
t('-1585782773394.4', '-1585782773394.44501382110847', 1);
t('-7604844176594943774211951887242195107.399', '-7604844176594943774211951887242195107.399576743428669618164', 3);
t('-0.00', '-0.0000000000000005153003506839', 2);
t('0.000', '0.00003', 3);
t('-5454249481540317712.560293859013731302', '-5454249481540317712.56029385901373130215526009738012974642338', 18);
t('15352607654972198961429295651185206861818141054385638.00000000000000000', '15352607654972198961429295651185206861818141054385638', 17);
t('91494535411039025233040.292', '91494535411039025233040.29224903220309368507011', 3);
t('2043369316.0', '2043369316', 1);
t('-0.0000000782350618457', '-0.0000000782350618457630647420312027682238301541350414', 19);
t('2122652.0', '2122652', 1);
t('-0.00841365', '-0.00841365099301981489219310202029642', 8);
t('0.0', '0.0007035', 1);
t('-0.00000000000000374916', '-0.0000000000000037491685778894015479084539735777088', 20);
t('534883638.00', '534883638', 2);
t('-2.0', '-2', 1);
t('-5634442247266825358399629799939027370665.0000000000000000000', '-5634442247266825358399629799939027370665', 19);
t('3331187169219186569122.000000000', '3331187169219186569122', 9);
t('0.0000000000', '0.0000000000006604395609805032330367635527', 10);
t('-0.0000000000000576901', '-0.00000000000005769013292086168690493327', 19);
t('-661.8', '-661.828596629053201916486', 1);
t('-6073555395665254434249128854999349235744174928042756.1153000000000', '-6073555395665254434249128854999349235744174928042756.1153', 13);
t('-5013086846966.000', '-5013086846966', 3);
t('0.004015', '0.00401523226833', 6);
t('3140295374107374579919222510.1462722', '3140295374107374579919222510.1462722819395532', 7);
t('-0.000000', '-0.00000000000000799876460379334679831886', 6);
t('-0.00', '-0.0003', 2);
t('-0.026760766726884267', '-0.026760766726884267750393307117624838556001925491', 18);
t('-20821740502968847857923433558797.0899', '-20821740502968847857923433558797.08997487843745', 4);
t('0.00000000002', '0.000000000020346524414696573703092255317751132892', 11);
t('45492073832204366341299301624.000000000', '45492073832204366341299301624', 9);
Decimal.rounding = 2;
t('7810971819938620325901899057970512790433.0000000000000000', '7810971819938620325901899057970512790433', 16);
t('-623395.0', '-623395', 1);
t('81334094079413997693749807.000000000000', '81334094079413997693749807', 12);
t('790143966.5', '790143966.406169480041929356421', 1);
t('-0.000485', '-0.0004851099615478', 6);
t('843581583868277359263.9721265', '843581583868277359263.97212648230399373761717', 7);
t('-921038771017147427324121032.000000', '-921038771017147427324121032', 6);
t('-823.0', '-823', 1);
t('505.0', '505', 1);
t('-866703339332502.8636000', '-866703339332502.8636', 7);
t('46.0', '46', 1);
t('60042202798790129685.0000000', '60042202798790129685', 7);
t('-1847392.0000', '-1847392', 4);
t('-4580251343840510165820631684073999841789879.0000000000000000000000', '-4580251343840510165820631684073999841789879', 22);
t('3501378778000.539063748827265447', '3501378778000.5390637488272654464266281832626835121535730779', 18);
t('0.000000004686', '0.000000004685387489140232', 12);
t('-0.0', '-0.0006', 1);
t('-445677508.00', '-445677508', 2);
t('0.0002', '0.00015099822561012723', 4);
t('-2992505698074499692367794831646886.0000000000000000', '-2992505698074499692367794831646886', 16);
t('5297873.59', '5297873.5869265978056497873793730268', 2);
t('72978439324039191443182.00000000000', '72978439324039191443182', 11);
t('0.66028387', '0.660283869505570207917431271006277981914716620876', 8);
t('-232008389442485.0', '-232008389442485', 1);
t('-2.371568', '-2.37156855939356279513952542004820909', 6);
t('731916154123696.1935', '731916154123696.193488323779184681349292529227446', 4);
t('-793941153937799250384382615553258074.00000', '-793941153937799250384382615553258074', 5);
t('651002.00', '651002', 2);
t('-61317874871.00', '-61317874871', 2);
t('8673.00', '8673', 2);
t('-14490519736189597435728386282.030655', '-14490519736189597435728386282.0306558561264348956674', 6);
t('0.001', '0.00000000000002', 3);
t('0.000009', '0.000008920984342', 6);
t('0.0000920957086395973679873', '0.000092095708639597367987279557138375172816422475', 25);
t('28125849913667924088615.25407023317734', '28125849913667924088615.2540702331773399078402875044891', 14);
t('87.55538597', '87.55538596435839691343147', 8);
t('939705902083425775202905619379.0000000', '939705902083425775202905619379', 7);
t('7303936681469130614.8345000', '7303936681469130614.8345', 7);
t('-5831852886782.68010000', '-5831852886782.6801', 8);
t('-0.0000000', '-0.0000000213769530812', 7);
Decimal.rounding = 3;
t('0.0000', '0.00000000000584', 4);
t('-79055907138737329232.165677999092552368', '-79055907138737329232.1656779990925523674', 18);
t('47206303530045536472421888342339.00000000', '47206303530045536472421888342339', 8);
t('3974.0', '3974', 1);
t('1296297430771.39', '1296297430771.391670729445980444292', 2);
t('0.000016', '0.00001686928031', 6);
t('-0.00001', '-0.0000000000008', 5);
t('4883938724383.000', '4883938724383', 3);
t('-5.4115622307', '-5.411562230628539329345282639155988044655000352687981880842', 10);
t('-0.01', '-0.0000000000155280115429218804426906540524', 2);
t('-2730930776035874709906.00000', '-2730930776035874709906', 5);
t('8419336352549424092369623.00000', '8419336352549424092369623', 5);
t('52897.4', '52897.4', 1);
t('-783171007682720320053252521365465473997085.0', '-783171007682720320053252521365465473997085', 1);
t('0.8', '0.8', 1);
t('-0.00000000085280', '-0.000000000852796916216780032747621063045628213284', 14);
t('809486781065644418.9', '809486781065644418.939', 1);
t('-9.0', '-9', 1);
t('2399395.00', '2399395', 2);
t('-243707862514768528758611224374.0000000000000', '-243707862514768528758611224374', 13);
t('-87906.00', '-87906', 2);
t('-36206954271055061276640398631031143034683624940748.9970000000000000000000', '-36206954271055061276640398631031143034683624940748.997', 22);
t('0.00', '0.0000000000565885579252765288683939564608114096713', 2);
t('-8391656174313988740342135972218668561645437.0', '-8391656174313988740342135972218668561645437', 1);
t('2798706581453003.177239111', '2798706581453003.17723911167031', 9);
t('607781292230803273523112111.091726721140', '607781292230803273523112111.09172672114', 12);
t('-0.3', '-0.3', 1);
t('3008522535782692059736852844809784198247000184.0', '3008522535782692059736852844809784198247000184', 1);
t('14227.00', '14227', 2);
t('7841760307718014116576857993957.0000', '7841760307718014116576857993957', 4);
t('-0.00001', '-0.00000000000002596', 5);
t('5247199732982111073.000000000', '5247199732982111073', 9);
t('-12.0', '-12', 1);
t('0.000', '0.00005', 3);
t('-1383703062.0000', '-1383703062', 4);
t('0.0051019245305169', '0.00510192453051698060366202631871161193', 16);
t('-45565092550117861497905653558246322559799.0', '-45565092550117861497905653558246322559799', 1);
t('-0.284', '-0.284', 3);
t('-8962.00', '-8962', 2);
t('49335989571.2173023', '49335989571.217302304037', 7);
Decimal.rounding = 4;
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('733744593401073823825766410831877679446.0000000000000000000', '733744593401073823825766410831877679446', 19);
t('-64.6849459', '-64.6849458687691227978', 7);
t('-0.000000', '-0.00000000009', 6);
t('-62537287527837589298857228059657673223234916.95923265430000000', '-62537287527837589298857228059657673223234916.9592326543', 17);
t('3393668096256773847245721315080265089731.000000', '3393668096256773847245721315080265089731', 6);
t('0.0', '0.0000000000000056674956638008432348702401392', 1);
t('72516372734.6', '72516372734.6447', 1);
t('-418.28', '-418.2800731793741351', 2);
t('0.00', '0.001', 2);
t('8366217346845756726.00000000', '8366217346845756726', 8);
t('-0.000000', '-0.0000000000000092034548636370987112234384736726', 6);
t('0.35', '0.35474830751442135112334772517193392', 2);
t('64703289793894.5830', '64703289793894.58296866', 4);
t('-0.000000000000000036', '-0.000000000000000036461242408590182363418943891', 18);
t('5494508405056449117588.631948', '5494508405056449117588.631948458033233759999', 6);
t('-0.0', '-0.00393971618499838726739122333520030506235698', 1);
t('375581290738585826632.00000000', '375581290738585826632', 8);
t('254.96635275802300887', '254.96635275802300886544776010389418575738792480979736', 17);
t('21492347.69467571391498624445', '21492347.6946757139149862444482880595559468', 20);
t('313576441324233.0000000', '313576441324233', 7);
t('-534460490015293367127173277346694900936058.0000', '-534460490015293367127173277346694900936058', 4);
t('182707431911537249021116759327712693311898345504618668.43327000000000000000000', '182707431911537249021116759327712693311898345504618668.43327', 23);
t('210005324615278.4586839690045963321032', '210005324615278.458683969004596332103244549279', 22);
t('779837001772884165637922377221951347134695.644834', '779837001772884165637922377221951347134695.6448338', 6);
t('-0.000001', '-0.00000064188301390033596845335767993853284632527964514979079', 6);
t('13.0', '13', 1);
t('0.0000001269', '0.0000001269060795648365813491128357427111184222', 10);
t('18446632248354.00', '18446632248354', 2);
t('-1229249.79', '-1229249.7897249259', 2);
t('49082.0', '49082', 1);
t('-61.0', '-61', 1);
t('-893.0', '-893', 1);
t('5002282278.56974877690066484', '5002282278.569748776900664839184116538222902', 17);
t('41372.00', '41372', 2);
t('-4732022445962399687294885123498809.7625585825095', '-4732022445962399687294885123498809.7625585825095', 13);
t('-55484242.036895641', '-55484242.036895641', 9);
t('-41427133134.52583323427907663268339', '-41427133134.525833234279076632683393992706825', 23);
t('0.0', '0.00004300614085218825243480119971669264977421', 1);
t('-472025754597316278339412186866.7010659789', '-472025754597316278339412186866.701065978877597089729906019843', 10);
Decimal.rounding = 5;
t('0.00', '0.00000000000000070362', 2);
t('682377946933004839.0000000', '682377946933004839', 7);
t('0.000000000', '0.00000000000000301722508588270616971784651380892069087869575', 9);
t('-356330174906.7', '-356330174906.737986270704', 1);
t('771875969530483104163034745359742192923504.000000000000000', '771875969530483104163034745359742192923504', 15);
t('-85.57612133364', '-85.576121333642541652128540737082', 11);
t('-796870619982006783.00000000', '-796870619982006783', 8);
t('985819.0', '985819', 1);
t('0.000000', '0.00000000000000000007093034243958', 6);
t('-0.0000', '-0.0000000006400178083107075310177579449', 4);
t('-105570971372984.0', '-105570971372984', 1);
t('4387745564661852845308.94229815083918', '4387745564661852845308.9422981508391799473309882', 14);
t('-3978043797116373.2', '-3978043797116373.159631', 1);
t('5.8961281424853232622595', '5.8961281424853232622594846548715356650909645537495738043051', 22);
t('-0.0000081539970551874384495', '-0.000008153997055187438449482684680130340977472796176926', 25);
t('-65.0', '-65', 1);
t('-24012940205869.000', '-24012940205869', 3);
t('0.000000', '0.000000000000000066985234999507396', 6);
t('2935194283452.35738951157832206907124', '2935194283452.357389511578322069071242729133894', 23);
t('542060.7771', '542060.77713479586821060591807145320317', 4);
t('890815036528241639534803534813.592588608837168425865025', '890815036528241639534803534813.59258860883716842586502472472', 24);
t('685877749980391051.17', '685877749980391051.1715', 2);
t('47820177163147405231185068730213.894293', '47820177163147405231185068730213.89429254869826585947429821', 6);
t('1536364305.00', '1536364305', 2);
t('-85825125.5810188', '-85825125.5810188298', 7);
t('-4983288214158634188.4572989', '-4983288214158634188.4572988600705359104', 7);
t('0.0000000000', '0.0000000000000000017929073', 10);
t('-1684136337600384671.00000000', '-1684136337600384671', 8);
t('567733137127609543.000000', '567733137127609543', 6);
t('607675679770387.000', '607675679770387', 3);
t('43727409067319.0', '43727409067319', 1);
t('-77274559773372606.00', '-77274559773372606', 2);
t('-28855643486070486857836.00000', '-28855643486070486857836', 5);
t('-915356570870.00', '-915356570870.00041832252262829437239', 2);
t('0.0', '0.00000000000004843552301428650828', 1);
Decimal.rounding = 6;
t('-6614662975368684488885953285955838893900074215956.00', '-6614662975368684488885953285955838893900074215956', 2);
t('8642393776898.000', '8642393776898', 3);
t('3612207878528.1106344698085142865', '3612207878528.1106344698085142865438924419', 19);
t('977910386.93', '977910386.9343537', 2);
t('-8937937492688941768401276851642629965923372.0', '-8937937492688941768401276851642629965923372', 1);
t('-8327876772303865517454752161.4376112752921904774', '-8327876772303865517454752161.43761127529219047742910886', 19);
t('-27707.00', '-27707', 2);
t('-7287595765894242586375.92700435484', '-7287595765894242586375.927004354837723619581861634319', 11);
t('-0.00000', '-0.000000000000023670858459165486137218740358207859', 5);
t('574676836802209077.64156', '574676836802209077.641563875647945277493356873895', 5);
t('-3041038455237222898218053653661.87952947815', '-3041038455237222898218053653661.87952947815', 11);
t('-628244132307.000', '-628244132307', 3);
t('316566935167341670725238.000', '316566935167341670725238', 3);
t('-77953301569468294124105528.0', '-77953301569468294124105528', 1);
t('0.0046', '0.00460227833968584', 4);
t('4323265763616518980379929221104.0', '4323265763616518980379929221104', 1);
t('1674500565014237781637959673471730398.1120033', '1674500565014237781637959673471730398.1120032995511774', 7);
t('872559441430499650732600166.00000', '872559441430499650732600166', 5);
t('-87858304.0000', '-87858304', 4);
t('-4158788.000', '-4158788', 3);
t('3983930437416823631395.9093', '3983930437416823631395.90934402583657', 4);
t('-14.5531937', '-14.5531936852106573016020290135814233645752955297443336', 7);
t('0.00000000002201', '0.00000000002200503795474854372849141363413146996972', 14);
t('0.0000000000000', '0.00000000000000000894955653982033503846831364474746320232', 13);
t('61564779.00', '61564779', 2);
t('-7.0', '-7', 1);
t('-0.000000000000028455976228', '-0.00000000000002845597622815028653703372125435938812845106', 24);
t('728982423193598397582409707715766595902844.0000000', '728982423193598397582409707715766595902844', 7);
t('14538075860529.2697937480', '14538075860529.269793748', 10);
t('0.000', '0.00000000000000000007021566096', 3);
t('-5136066535080.86830591678842264063462546263', '-5136066535080.86830591678842264063462546262988980471309228558', 29);
t('-3026751112367460839746524832112404665.000000000000000', '-3026751112367460839746524832112404665', 15);
t('0.5', '0.5');
t('-0', '-0.5', 0);
t('10.5', '10.5');
t('0.05', '0.05');
t('0.4', '0.4');
t('0.6', '0.6');
t('1.5', '1.5');
t('-1.5', '-1.5');
Decimal.rounding = 4;
t('-535564000.00', '-535564000', 2);
t('-80000000.000', '-80000000', 3);
t('-240.0', '-240', 1);
t('-7520000000.0', '-7520000000', 1);
t('306550.000', '306550', 3);
t('800000000.0', '800000000', 1);
t('-454000000.00000', '-454000000', 5);
t('60.0', '60', 1);
t('-4700000.000', '-4700000', 3);
t('25000.00', '25000', 2);
t('6847.0', '6847', 1);
t('780.0', '780', 1);
t('-50.0', '-50', 1);
t('700.0', '700', 1);
t('412598000.0000', '412598000', 4);
t('-84581600.0', '-84581600', 1);
t('5590000.00', '5590000', 2);
t('-66000.0', '-66000', 1);
t('600.0', '600', 1);
t('-513335000.000', '-513335000', 3);
t('-40.0', '-40', 1);
t('-52536202527.13891931933498708496518913773517016037224', '-5.253620252713891931933498708496518913773517016037224E10');
t('0.0000000000000008761383898703999300297605784533730922', '8.761383898703999300297605784533730922E-16');
t('-0.0000000000000000000000000000000000004', '-4E-37');
t('2832044194940.47654015529986948208', '2.83204419494047654015529986948208E12');
t('0.00000000000000000000000064668155275864837', '6.4668155275864837E-25');
t('4.34128088694', '4.34128088694E0');
t('-851957.6572615611436542', '-8.519576572615611436542E5');
t('-89097468286.2561077879598798580253771544265682053', '-8.90974682862561077879598798580253771544265682053E10');
t('-0.000000000000000000000000000000000000000000000030409767', '-3.0409767E-47');
t('0.000000000000000000004295112484112357722747956581254', '4.295112484112357722747956581254E-21');
t('-839203207475651.6542808578', '-8.392032074756516542808578E14');
t('-0.00000000000000000078216', '-7.8216E-19');
t('-1782290274935701247734.21262413032385', '-1.78229027493570124773421262413032385E21');
t('31669451104144801337076433457.18511076', '3.166945110414480133707643345718511076E28');
t('0.000000000000000000000000000000000000472351852761', '4.72351852761E-37');
t('-50155220217523568901083623.78842580174913602672593731', '-5.015522021752356890108362378842580174913602672593731E25');
t('-291.37', '-2.9137E2');
t('-52474611936456205886027195352961212383.2279441143', '-5.24746119364562058860271953529612123832279441143E37');
t('-326.9376463292543', '-3.269376463292543E2');
t('0.00000000000044', '4.4E-13');
t('0.000000087792449', '8.7792449E-8');
t('497835793870987132484033.938845920610565887398960253648', '4.97835793870987132484033938845920610565887398960253648E23');
t('-33960439442302770058.74863962', '-3.396043944230277005874863962E19');
t('0.00000000000000000000000000000000000000020694696587293782', '2.0694696587293782E-40');
t('123.45', '123.45');
t('123', '123.45', 0);
t('123', '123.45', -0);
tx(function () {new Decimal(1.23).toFixed('3')}, "(1.23).toFixed('3')");
tx(function () {new Decimal(1.23).toFixed(new Decimal('3'))}, "(1.23).toFixed(new Decimal('3'))");
tx(function () {new Decimal(1.23).toFixed(null)}, "(1.23).toFixed(null)");
tx(function () {new Decimal(1.23).toFixed(NaN)}, "(1.23).toFixed(NaN)");
tx(function () {new Decimal(1.23).toFixed('NaN')}, "(1.23).toFixed('NaN')");
tx(function () {new Decimal(1.23).toFixed([])}, "(1.23).toFixed([])");
tx(function () {new Decimal(1.23).toFixed({})}, "(1.23).toFixed({})");
tx(function () {new Decimal(1.23).toFixed('')}, "(1.23).toFixed('')");
tx(function () {new Decimal(1.23).toFixed(' ')}, "(1.23).toFixed(' ')");
tx(function () {new Decimal(1.23).toFixed('hello')}, "(1.23).toFixed('hello')");
tx(function () {new Decimal(1.23).toFixed('\t')}, "(1.23).toFixed('\t')");
tx(function () {new Decimal(1.23).toFixed(new Date)}, "(1.23).toFixed(new Date)");
tx(function () {new Decimal(1.23).toFixed(new RegExp)}, "(1.23).toFixed(new RegExp)");
tx(function () {new Decimal(1.23).toFixed(2.01)}, "(1.23).toFixed(2.01)");
tx(function () {new Decimal(1.23).toFixed(10.5)}, "(1.23).toFixed(10.5)");
tx(function () {new Decimal(1.23).toFixed('1.1e1')}, "(1.23).toFixed('1.1e1')");
tx(function () {new Decimal(1.23).toFixed(true)}, "(1.23).toFixed(true)");
tx(function () {new Decimal(1.23).toFixed(false)}, "(1.23).toFixed(false)");
tx(function () {new Decimal(1.23).toFixed(function (){})}, "(1.23).toFixed(function (){})");
tx(function () {new Decimal('123.45').toFixed(1e9 + 1)}, ".toFixed(1e9 + 1)");
tx(function () {new Decimal('123.45').toFixed('-0.01')}, ".toFixed('-0.01')");
tx(function () {new Decimal('123.45').toFixed('-1e-1')}, ".toFixed('-1e-1')");
tx(function () {new Decimal('123.45').toFixed(Infinity)}, ".toFixed(Infinity)");
tx(function () {new Decimal('123.45').toFixed('-Infinity')}, ".toFixed('-Infinity')");
tx(function () {new Decimal(1.23).toFixed(1, '3')}, "(1.23).toFixed(1, '3')");
tx(function () {new Decimal(1.23).toFixed(1, new Decimal('3'))}, "(1.23).toFixed(1, new Decimal('3'))");
tx(function () {new Decimal(1.23).toFixed(1, null)}, "(1.23).toFixed(1, null)");
tx(function () {new Decimal(1.23).toFixed(1, NaN)}, "(1.23).toFixed(1, NaN)");
tx(function () {new Decimal(1.23).toFixed(1, 'NaN')}, "(1.23).toFixed(1, 'NaN')");
tx(function () {new Decimal(1.23).toFixed(1, [])}, "(1.23).toFixed(1, [])");
tx(function () {new Decimal(1.23).toFixed(1, {})}, "(1.23).toFixed(1, {})");
tx(function () {new Decimal(1.23).toFixed(1, '')}, "(1.23).toFixed(1, '')");
tx(function () {new Decimal(1.23).toFixed(1, ' ')}, "(1.23).toFixed(1, ' ')");
tx(function () {new Decimal(1.23).toFixed(1, 'hello')}, "(1.23).toFixed(1, 'hello')");
tx(function () {new Decimal(1.23).toFixed(1, '\t')}, "(1.23).toFixed(1, '\t')");
tx(function () {new Decimal(1.23).toFixed(1, new Date)}, "(1.23).toFixed(1, new Date)");
tx(function () {new Decimal(1.23).toFixed(1, new RegExp)}, "(1.23).toFixed(1, new RegExp)");
tx(function () {new Decimal(1.23).toFixed(1, 2.01)}, "(1.23).toFixed(1, 2.01)");
tx(function () {new Decimal(1.23).toFixed(1, 10.5)}, "(1.23).toFixed(1, 10.5)");
tx(function () {new Decimal(1.23).toFixed(1, '1.1e1')}, "(1.23).toFixed(1, '1.1e1')");
tx(function () {new Decimal(1.23).toFixed(1, true)}, "(1.23).toFixed(1, true)");
tx(function () {new Decimal(1.23).toFixed(1, false)}, "(1.23).toFixed(1, false)");
tx(function () {new Decimal(1.23).toFixed(1, function (){})}, "(1.23).toFixed(1, function (){})");
tx(function () {new Decimal('123.45').toFixed(1, 9)}, ".toFixed(1, 9)");
tx(function () {new Decimal('123.45').toFixed(1, '-0.01')}, ".toFixed(1, '-0.01')");
tx(function () {new Decimal('123.45').toFixed(1, '-1e-1')}, ".toFixed(1, '-1e-1')");
tx(function () {new Decimal('123.45').toFixed(1, Infinity)}, ".toFixed(1, Infinity)");
tx(function () {new Decimal('123.45').toFixed(1, '-Infinity')}, ".toFixed(1, '-Infinity')");
// ROUND_HALF_CEIL
// Rounds towards nearest neighbour. If equidistant, rounds towards Infinity
Decimal.rounding = 7;
t('0.1', '0.05', 1);
t('1', 0.5, 0);
t('1', 0.54, 0);
t('1', 0.55, 0);
t('1', 0.56, 0);
t('-1', -0.54, 0);
t('-0', -0.5, 0);
t('-1', -0.56, 0);
t('-0.5', -0.5, 1);
t('1.3', 1.25, 1);
t('-1.2', -1.25, 1);
t('234.2041', 234.20405, 4);
t('-234.2040', -234.20405, 4);
t('234.2041', '234.204050000000000000000000000000006', 4);
t('-234.2045', '-234.20449', 4);
t('-234.2041', '-234.204050000000000000000000000000006', 4);
t('999.0', 999, 1);
t('1000', 999.5, 0);
t('-999', -999.5, 0);
t('-999.5', -999.5, 1);
t('1.00000000000000000', '1.000000000000000000005', 17)
t('1.00000000000000000001', '1.000000000000000000005', 20)
t('-1.00000000000000000', '-1.000000000000000000005', 17)
t('-1.00000000000000000000', '-1.000000000000000000005', 20)
// ROUND_HALF_FLOOR
// Rounds towards nearest neighbour. If equidistant, rounds towards -Infinity
Decimal.rounding = 8;
t('0.0', '0.05', 1);
t('0', 0.5, 0);
t('1', 0.54, 0);
t('1', 0.55, 0);
t('1', 0.56, 0);
t('-1', -0.54, 0);
t('-1', -0.5, 0);
t('-1', -0.56, 0);
t('-0.5', -0.5, 1);
t('1.2', 1.25, 1);
t('-1.3', -1.25, 1);
t('234.2040', 234.20405, 4);
t('-234.2041', -234.20405, 4);
t('234.2040', '234.20404999999999999999999999999999', 4);
t('234.2041', '234.204050000000000000000000000000006', 4);
t('-234.2045', '-234.20449', 4);
t('-234.2041', '-234.204050000000000000000000000000006', 4);
t('999.0', 999, 1);
t('999', 999.5, 0);
t('-1000', -999.5, 0);
t('-999.5', -999.5, 1);
t('1.00000000000000000', '1.000000000000000000005', 17);
t('1.00000000000000000000', '1.000000000000000000005', 20);
t('-1.00000000000000000', '-1.000000000000000000005', 17);
t('-1.00000000000000000001', '-1.000000000000000000005', 20);
T.stop();
})();

234
test/modules/toFraction.js Normal file
View File

@ -0,0 +1,234 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toFraction');
function t(expected, n, maxDenominator) {
T.assertEqual(expected, new Decimal(n).toFraction(maxDenominator).toString());
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('1,10', '0.1');
t('-1,10', '-0.1');
t('1,100', '0.01');
t('-1,100', '-0.01');
t('1,1000', '0.001');
t('-1,1000', '-0.001');
t('54301793,100000', '543.017930');
t('-484693350148251574449,1000000000000', '-484693350.1482515744490');
t('-200111074540568980159529,25000000000000', '-8004442981.622759206381160');
t('-5965700213104829,1000000000000000', '-5.965700213104829');
t('-5124110209739113904928179,100000000000000', '-51241102097.39113904928179');
t('-1655017182533520595664837541,200000000000000', '-8275085912667.602978324187705');
t('-5,8', '-0.625');
t('-42394617,200000000', '-0.211973085');
t('-147453708173963291829,2500000000000000000', '-58.9814832695853167316');
t('-2733,100', '-27.33');
t('0,1', '0.0');
t('-2599897551866392365731491641,10000000000', '-259989755186639236.5731491641');
t('-9326331230765073371,5000000000000000', '-1865.2662461530146742');
t('-2483061,10000', '-248.3061');
t('-92864854181,10000000', '-9286.4854181');
t('-758516850228215193,100000000000000000', '-7.5851685022821519300');
t('-19570408085559589,20000000000', '-978520.404277979450');
t('-211,100', '-2.11');
t('-4789334439841,10000000000', '-478.9334439841');
t('2978320663077,10000000000000', '0.2978320663077');
t('-1221,25', '-48.84');
t('12456254053601331,5000000000000', '2491.25081072026620');
t('31969983,100000', '319.69983');
t('31852901149,400000000000', '0.0796322528725');
t('-456674099059,10000000000', '-45.6674099059');
t('-361907787,5000000', '-72.3815574');
t('-6521,100', '-65.21');
t('5,1', '5.1582612935891', '3');
t('14645,1797', '8.14969395596340', '4682');
t('350921,81990', '4.28004634702', '82418');
t('923754598113149102531799372705758450549,100000000', '9237545981131491025317993727057.58450549');
t('23665467152910525354658972818814752082,49447', '478602688796297558085606261629921.9787246948249979233505266225354557384', '57466');
t('12401124714135748113774134798397,2', '6200562357067874056887067399198.66971421701', '2');
t('5747456325233732815460960864983211610837351385715799969377,100000000000000000000000000000', '57474563252337328154609608649.83211610837351385715799969377');
t('4744,61', '77.7705294446793765233206385561288346447', '86');
t('230406626515463254737498487452583023685806305331639,100000000000000000000000000', '2304066265154632547374984.87452583023685806305331639');
t('8452816572418429518944119647,5000', '1690563314483685903788823.9294');
t('48239499471878294436129777581,10000000000000000', '4823949947187.82944361297775810');
t('45172634468362586403517152343110493066053,74300', '607976237797612199239800166125309462.530995962577562', '89241');
t('245629009658126699398365025147112883705717,1250000000000000000000000000000', '196503207726.5013595186920201176903069645736');
t('19575206081236584421562241755643406299,500000000000000000000000000000000000', '39.150412162473168843124483511286812598');
t('124335953351113119989680198250484096210027176457861877,20000000000000000000000', '6216797667555655999484009912524.20481050135882289309385');
t('62359286968916651021817694022163661098254437249041482587,100000000000000000000000000', '623592869689166510218176940221.63661098254437249041482587');
t('1406253392003122107350210973,50', '28125067840062442147004219.46', '90');
t('736337826,1', '736337826.0', '1');
t('2294354321,3019', '759971.62007285863174441704674479534091075', '5946');
t('342555042697121035185957633789368546657896318423873,50000000000000000000000000', '6851100853942420703719152.67578737093315792636847746');
t('3511582655801640591,52', '67530435688493088.2885316751682999639624370547426320', '73');
t('1190687310674838338273481559,50000', '23813746213496766765469.63118');
t('31747884008318370382077439489,40', '793697100207959259551935987.225181146039', '45');
t('39451289109544785156061546711681,59993', '657598204949657212609163514.271348320970259397527780637349273932', '61325');
t('3859539118592118171061,65', '59377524901417202631.7076617756627530296590420377861', '248');
t('2529860848590369124121129138,36761', '68819152052184900414056.449443703377131320899467509', '59208');
t('17331073,2', '8665536.3781112033855216846406980971689', '2');
t('11088761069693879,25000', '443550442787.75516');
t('37298162459148947522489,474', '78688106453900733169.80801275320205353359142143262532', '517');
t('12411782390212011049587005051032466579057,100000000000000000000000000000000000000', '124.11782390212011049587005051032466579057');
t('288377889236302421024476469650301879883847,50000000000000000000000', '5767557784726048420.48952939300603759767694');
t('64269805556832147,1', '64269805556832146.8921574533060466484388410550211', '2');
t('1019428223041680221,2', '509714111520840110.44623631764611004359625363775303233110', '2');
t('-535739501101785482356483511,20000000000000000', '-26786975055.08927411782417555');
t('-2189002367733133,500000000000000', '-4.378004735466266');
t('-4135862533810979636019397675000,1', '-4.135862533810979636019397675E+30');
t('-14984699501047789,1000000000000', '-14984.699501047789');
t('-2644213426631746862661931503,10000', '-264421342663174686266193.1503');
t('-2092299259157497414090361017,5', '-418459851831499482818072203.4');
t('-77,100', '-0.77');
t('-54276151887,1000000000', '-54.276151887');
t('-389683579126928886377631531,2500000000000000', '-155873431650.7715545510526124');
t('46789726161807116524384304297700033991397937633588752307,10000000000000000000000000000000000000', '4678972616180711652.4384304297700033991397937633588752307');
t('-9196858034762943045297291137,10000', '-919685803476294304529729.1137');
t('-12757819,25000', '-510.31276');
t('-2751580109664699528322719473,50', '-55031602193293990566454389.46');
t('-1397067073903866232334961397,200000000000', '-6985335369519331.161674806985');
t('-10827300142961420614583582960000000000000000000000000000000000000000000,1', '-1.082730014296142061458358296E+70');
t('488478745829,50000000', '9769.57491658');
t('-2319703638146144907642415179,250000000000000000000000000', '-9.278814552584579630569660716');
t('8199609,1000000', '8.199609');
t('-1132520281920903148966859641,50000000000', '-22650405638418062.97933719282');
t('-9435372448691264711,10000000000', '-943537244.8691264711');
t('-5430432705270926972283794348000000000000000,1', '-5.430432705270926972283794348E+42');
t('2547106921,10000000', '254.7106921');
t('-2013361060932518973304030049,250000000000', '-8053444243730075.893216120196');
t('-299071373209294751127694543,4000', '-74767843302323687781923.63575');
t('161261,5000', '32.2522');
t('-2149015945426180798371334522,1', '-2149015945426180798371334522');
t('-1219052557726696173105236523,1250000000000000', '-975242046181.3569384841892184');
t('-6635702255618430700913831019,1000000', '-6635702255618430700913.831019');
t('-4229092410987972953057006873,100', '-42290924109879729530570068.73');
t('800876757958087347097942687332875742929708200305858327085977609,100000000000000000000000000000000000', '8008767579580873470979426873.32875742929708200305858327085977609');
t('-2665484396670548074136945193,50', '-53309687933410961482738903.86');
t('30396,38195', '0.79581097', '74409');
t('2125057574,3289', '646110.5424140842277760913716223149175043516912866283522989430448583852673477181054', '4314');
t('18251,16', '1140.688086121119279582816178812726653910', '37');
t('61348765027081784476232889631422618917241085602257,2', '30674382513540892238116444815711309458620542801128.559859020834676491532682063017825303001913079937413732204504474950978211332225018371420', '2');
t('238354711696434965227174225040046402291933791409568617910,25981', '9174193129457486826033417691391647830796882006449660.0558100148468970808679278895365813792370050009058167954469', '61710');
t('7355967799241738309628763754835483150582416687842544374137,8', '919495974905217288703595469354435393822802085980318046767.1338999658963927824509929378965804777221331548975659545056488845295998946309871474144010438', '9');
t('1125354937387110207464744146511518,247481', '4547237716782743755943866989.8356560705677241346146759866583370949', '863202');
t('58400904696,8737', '6684320.09797413893379904985072385250774250364224704531308514779353223', '14426');
t('4765998700799,481932', '9889359.28886025414277', '551989');
t('84446319074008288318841993796319916,1', '84446319074008288318841993796319916.4290214679797552828327089099139280188', '1');
t('208579935771852505416338,29', '7192411578339741566080.621098672624218880520368888346887640903578755437931806539999680994582938', '38');
t('1006862373895650813218257996159822111779222738385202718573234201031,335', '3005559325061644218561964167641260035161858920552843936039505077.70447752609278095294701366298104650604976387611568135143174113323780682', '7063');
t('12180512204,290477', '41932.7940043445804168810482554121918927813650259', '895566');
t('972851014381591,18170', '53541607836.080957621939096312239677792878740188648258030024875', '31555');
t('383576424003665,59', '6501295322096.01707059843465672720153308', '88');
t('456059695649,731697', '623290.372447884850674344473049816049238992052574671', '770999');
t('1,2', '0.5716202415873544262986953173753852278285193332218646822626651', '2');
t('13802410789886736953383903846755867001633124596437299605748175709981308048573814,2523', '5470634478750193005701111314607953627282253109963257869896225013864965536493.782798186996737913044082377221550214034629772236938011947896897722075720890727218714', '2580');
t('1720546690653497270570006270472130851,1', '1720546690653497270570006270472130851.14006845543964920673232647491053082791301585407937041734157349507526701334664232654756777642845206', '1');
t('275492732803212658371830121443811803,6273', '43917221872024973437243762385431.5005579559793624838126175850466341579997661657132448932942532299', '11453');
t('88013352536654826423613115136850148349568967,93', '946380134802740069071108764912367186554505.02139414761736578247940104106009403877307019264568966335689948628094', '100');
t('0,1', '0.16188799510329961', '2');
t('31257777609885493076027897164441747647216000811363789460,63', '496155200156912588508379320070503930908190489069266499.364683462978985476107209780379101750930177884309470340386147403736530', '73');
t('-2991910323532143367251432461,50000000', '-59838206470642867345.02864922');
t('-972745200863972039012044288500000000000000000000000000000,1', '-9.727452008639720390120442885E+56');
t('-759,100', '-7.59');
t('-27827258151452494934863201,100', '-278272581514524949348632.0100');
t('-284626800809,50000000', '-5692.53601618');
t('-74421663208247269188483431,80000000000000000', '-930270790.1030908648560428875');
t('-1082016448333999416859837516000,1', '-1.082016448333999416859837516E+30');
t('-21,25', '-0.84');
t('-67246554173689300336047211,8000000', '-8405819271711162542.005901375');
t('-2196812392790282979771359770000000000000,1', '-2.196812392790282979771359770E+39');
t('-93367638440645772883402889310000,1', '-9.336763844064577288340288931E+31');
t('-35989199713272470893896397640000000000,1', '-3.598919971327247089389639764E+37');
t('-21641213684333939876179569040,1', '-2.164121368433393987617956904E+28');
t('-91309127692139566014327039220000000000000000000000000000000000000,1', '-9.130912769213956601432703922E+64');
t('-1991444477322661912100056959,50000000000', '-39828889546453238.24200113918');
t('-553515865616749148505592781,10000000000000000000000000', '-55.35158656167491485055927810');
t('-2736653830100392487693621031,500000', '-5473307660200784975387.242062');
t('-1434910778309587281399577109,5000000000', '-286982155661917456.2799154218');
t('7325643,10000000', '0.7325643');
t('8129753468709152191211051855224273832281,100000000000000000000000', '81297534687091521.91211051855224273832281');
t('26846080372036394639591396,6672793', '4023214922452471497.25630571786057289667012386513324609', '72150416');
t('151169465630612379481675652813336817561189321,200000000000000000000000000000000000000', '755847.328153061897408378264066684087805946605');
t('48650152878444478499756261104359,1000000', '48650152878444478499756261.104359');
t('310291026486294288245548,3136069', '98942665638509321.1423434879780971949357099446690852', '4194429');
t('281148949800335203180214,28247', '9953232194581201656.11264913171363754779711915', '40003');
t('8070991737,10', '807099173.7');
t('2105837647496797835243555428994974365746550495259,2500000000000000000000000', '842335058998719134097422.1715979897462986201981036');
t('7050549406715449007260719040610995681,100000000000000000000', '70505494067154490.07260719040610995681');
t('1485521639981158765714509531187624755829128849,100000000000000000000000', '14855216399811587657145.09531187624755829128849');
t('179195624045698698709602380291841534992963,397', '451374367873296470301265441541162556657.33752912', '654');
t('60786881043136,81', '750455321520.1975303545477874468301224681956212', '6955');
t('54350058946186575767248586,111', '489640170686365547452689.9639497075875189553277274425649764720088', '136');
t('207448313353211937938706154109749,2500000000000000000000000', '82979325.34128477517548246164389960');
t('18637328030895697373,20000000000', '931866401.54478486865');
t('77127230808472816894238711,10000000000000000', '7712723080.8472816894238711');
t('29126173556928305215214880165709856062,7', '4160881936704043602173554309387122294.5709328', '7');
t('43333053556734019842,614489', '70518843391393.531604308619475952242596538499476346', '675048');
t('53377793855957,559250504', '95445.231562915140439462747444833608100863907', '1363996915');
t('347448038601,1158528605', '299.9045833667611513140004251012084', '3206002475');
t('4723559025392992686163722415183139,100000000000000000000', '47235590253929.92686163722415183139');
t('178091379773085237300450763077988415217238,1811184275', '98328691470714782625004163686209.3533896422549273776361277', '1811232885');
t('805514724831305204420874185699445105715750883,100000000000000', '8055147248313052044208741856994.45105715750883');
t('65819,6849', '9.610016056348', '8529');
t('319168767950612554460346534967,625000000000000', '510670028720980.0871365544559472');
t('5710296907,88986', '64170.7336772078034895641687140263', '92775');
t('556588363946502498333308725135986051213680185539426551525214239244852201,500000000000000000000000000000000000000', '1113176727893004996666617450271972.102427360371078853103050428478489704402');
t('20826873980146981695459788919411033,31250000', '666459967364703414254713245.421153056');
t('2499361049528080561202511540068978284974386343138634241,1000000000000000000000000000000000000', '2499361049528080561.202511540068978284974386343138634241');
t('418298807255269058527019236340986131039447727889611856636829077,50000000000000000000000000000000000', '8365976145105381170540384726.81972262078895455779223713273658154');
t('6913324275323537689724784638569909,100000000000000', '69133242753235376897.24784638569909');
t('13962383460375585294405129665013837633,2000', '6981191730187792647202564832506918.8165');
t('2469,20', '123.45');
t('2469,20', '123.45', null);
t('2469,20', '123.45', '2.1e1');
t('1111,9', '123.45', new Decimal(10));
t('2469,20', '123.45', new Decimal('123e399'));
t('2469,20', '123.45', new Decimal('123'));
tx(function () {new Decimal('123.45').toFraction('')}, ".toFraction('')");
tx(function () {new Decimal('123.45').toFraction(' ')}, ".toFraction(' ')");
tx(function () {new Decimal('123.45').toFraction('\t')}, ".toFraction('\t')");
tx(function () {new Decimal('123.45').toFraction(NaN)}, ".toFraction(NaN)");
tx(function () {new Decimal('123.45').toFraction('NaN')}, ".toFraction('NaN')");
tx(function () {new Decimal('123.45').toFraction('hello')}, ".toFraction('hello')");
tx(function () {new Decimal('123.45').toFraction([])}, ".toFraction([])");
tx(function () {new Decimal('123.45').toFraction({})}, ".toFraction({})");
tx(function () {new Decimal('123.45').toFraction(true)}, ".toFraction(true)");
tx(function () {new Decimal('123.45').toFraction(false)}, ".toFraction(false)");
tx(function () {new Decimal('123.45').toFraction(function (){})}, ".toFraction(function (){})");
tx(function () {new Decimal('123.45').toFraction(new Number)}, ".toFraction(new Number)");
tx(function () {new Decimal('123.45').toFraction(new String)}, ".toFraction(new String)");
tx(function () {new Decimal('123.45').toFraction(new Date)},".toFraction(new Date)");
tx(function () {new Decimal('123.45').toFraction(new RegExp)}, ".toFraction(new RegExp)");
tx(function () {new Decimal('123.45').toFraction(7.5)}, ".toFraction(7.5)");
tx(function () {new Decimal('123.45').toFraction(new Decimal('225.435435'))}, ".toFraction(new Decimal('225.435435'))");
tx(function () {new Decimal('123.45').toFraction(0)}, ".toFraction(0)");
tx(function () {new Decimal('123.45').toFraction('0.99')}, ".toFraction('0.99')");
tx(function () {new Decimal('123.45').toFraction(-1)}, ".toFraction(-1)");
tx(function () {new Decimal('123.45').toFraction(-23)}, ".toFraction(-23)");
tx(function () {new Decimal('123.45').toFraction(Infinity)}, ".toFraction(Infinity)");
tx(function () {new Decimal('123.45').toFraction('-Infinity')}, ".toFraction('-Infinity')");
T.stop();
})();

345
test/modules/toHex.js Normal file
View File

@ -0,0 +1,345 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toHex');
var t = function (expected, n, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).toHex());
}
Decimal.config({
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', NaN, 20, 4);
t('NaN', 'NaN', 20, 4);
t('Infinity', Infinity, 20, 4);
t('-Infinity', -Infinity, 20, 4);
t('Infinity', 'Infinity', 20, 4);
t('-Infinity', '-Infinity', 20, 4);
// Integers
t('0x0', '0', 1, 4);
t('0x9', '9', 1, 4);
t('0x5a', '90', 2, 4);
t('0x0', '0', 1, 4);
t('-0x9', '-9', 1, 4);
t('-0x5a', '-90', 2, 4);
t('0xffffffff', '4294967295', 8, 4);
t('0x0', '0', 1, 4);
t('0x8.8', '8.5', 2, 4);
t('-0x8.8', '-8.5', 2, 4);
t('0x60bf8d3f1cb70827109c', '456880688358819786854556', 20, 4);
t('0x27', '39', 2, 4);
t('0x14a3b3', '1352627', 6, 4);
t('0xc8841d8a3e0c3184a1d13f24b7c8abcbf36', '1091713357762058306584556087055815769112374', 35, 4);
t('0x2266ce3388fee3c292256', '2599310186932964178862678', 21, 4);
t('0x784afb326df4e14f44919e903da2daab2c6a8c2b7', '10988016479801545098971638340838655979698598232759', 41, 4);
t('0x47d', '1149', 3, 4);
t('0x613b8b5', '101955765', 7, 4);
t('0x6b63', '27491', 4, 4);
t('0x2d3777760a984a21c97a0d20c628c419cab2bfc67f', '66084232243819558824679961490043082487366953191039', 42, 4);
t('0x12c9942167ae93c737fc5ff39d', '1488492491002839592133151683485', 26, 4);
t('0xc2c44', '797764', 5, 4);
t('0xfe787f84cf0ae7655d44db4e793b2a98ae8f', '22167524012235587957931446373184044722073231', 36, 4);
t('0x186b6b31486165c0bc8c778fd49af12ea08f7dad332', '571028668500605890623232664155788301681845784466226', 43, 4);
t('0x2aef3ee6f864b26772c23cf6', '13287600730756091106849602806', 24, 4);
t('0x193c4c1a69add29d9a5101ced0568697d923', '2198325248780085112365807036920470754023715', 36, 4);
t('0x11a507516c68d662f15d9', '1333191524844399246644697', 21, 4);
t('0xa2669c148f4ea9e', '731388268367899294', 15, 4);
t('0xed2a498f218583395d57871', '4587441849070983049702111345', 23, 4);
t('0x1fbbac5129573', '558254565528947', 13, 4);
t('0x1b91780b06a70cf46e5fa0fa8e63407e80030f027a', '40291024919626546988689644749021723762456102109818', 42, 4);
t('0x25a90a2b75d596836e10d26ec831', '763841862190387816235893777156145', 28, 4);
t('0xfbd45cc9e2', '1081599642082', 10, 4);
t('0x621e835f12ad64e909cf7', '7413676543182627283180791', 21, 4);
t('0x17de6483675cb29063c', '7044803064789933295164', 19, 4);
t('0x2ecc612', '49071634', 7, 4);
t('0x14bb4a5d83f3d4bf43b66adada6b0e993784', '1805977369681030296729705669300424034301828', 36, 4);
t('0x8b63e2dca39c336b18', '2571294983995377543960', 18, 4);
t('0x3c1440de515e09b31f73cdd0da6e2', '19496787444412678571409607909811938', 29, 4);
t('0xd39570c80caa28598ea432085259', '4291428326751199011126676862554713', 28, 4);
t('0x1d54a95161a44ae4d216da350d20954f13992a85', '167448744619550277927636746527062265701749828229', 40, 4);
t('0xe3ffcc64277a78a8256d7e1d7c05eaa9bf', '77584111689906087598180624752236124875199', 34, 4);
t('0x22f4736', '36652854', 7, 4);
t('0x2c35e4d05c0', '3038123984320', 11, 4);
t('0x430e68bd9ad4952', '301994663360678226', 15, 4);
t('0x1d854cf1f48c4529d864b686f2d', '37421939842938093643010520149805', 27, 4);
t('0x5db3324efd09a682cd', '1728459668785308533453', 18, 4);
t('0x1b60d2a23a53bc5a', '1972808230993378394', 16, 4);
t('0x1b7b2cc91769682ad42af60ef67c77c99ac81d227197', '10281919698706053870205728976619722313496732052386199', 44, 4);
t('0x78a9c9d91cb45ec86599f1b402f6635265b69a0317', '176349517282896190364726424897935661923732528169751', 42, 4);
t('0x310f7e944db1e20ca7d4db559be74aafcd', '16694431636419175813863637436681440374733', 34, 4);
t('0x11a4ae80f151dad1752e32c310a41dae552c37b7b4', '25785693883194456949802584063055012266517133244340', 42, 4);
t('0x320abd803f00618b853f0f4ad06d76e5ead8eb20d', '4571024861681675091071130733403917525672421929485', 41, 4);
t('0x17f27d4daa32a', '421284028261162', 13, 4);
t('0x3fd14203387143ed10002039a6fed', '20709934734392064809458286974365677', 29, 4);
t('0xddf93c33cbe97520fb19a19', '4293593374816726677147720217', 23, 4);
t('0x37bc13d810602438ce47db31c0e7a87e6b7831', '1242924848237600517379561065653635852461111345', 38, 4);
t('0x15a', '346', 3, 4);
t('0x533921', '5454113', 6, 4);
t('0x770d01b680082f7c23db6444c14f885dacb63824', '679659960629478197799609320106784570818809968676', 40, 4);
t('0x1d35', '7477', 4, 4);
t('0xaa906c1dabfebe6da', '196647076124632540890', 17, 4);
t('0x655', '1621', 3, 4);
t('0x11af668734ef7a60033c5f518c530', '5739161962048683655238213338449200', 29, 4);
t('0x9035964bc6d843d71d2ef9124632b039ca9ad9d6062cd', '863281823741412484448091339719676346358410323679011533', 45, 4);
t('0xfa3d98dfd239530c9a9556', '302522339292227790310118742', 22, 4);
t('0x10fdb7f', '17816447', 7, 4);
t('0x18d260c9d8f110eea9d29', '1875481379014053338979625', 21, 4);
t('0x6dc6205912265fe68cb44ae5c', '543574178265693146271925448284', 25, 4);
t('0x19d6ad933a8e5', '454557212846309', 13, 4);
t('0x3e1ddad6b81e605', '279748388776437253', 15, 4);
t('0xe073b0188f2d6667b75f11f65a82fda', '18646734802776877837813543784990388186', 31, 4);
t('0x81f531048349c33f91627d55e1b6bdd8a78', '707557451293532648521737780488438655322744', 35, 4);
t('0x78b8be03f14', '8295928577812', 11, 4);
t('0x8', '8', 1, 4);
t('0x659874ecb742089cd0f2fc72a2e912d48334f2d', '36250497918673919606249316600592246963107483437', 39, 4);
t('0x2a03a8a82cd13dc18b5', '12400430345351117674677', 19, 4);
t('0x1e634adab5f805f52f70cac738dd261d7d6', '165447251922571882378062853693168471365590', 35, 4);
t('0x2d0b0ae2b685425d29b0ecb3b5edfa717cb1417', '16071927572096392119675195392748578598193665047', 39, 4);
t('0x7a87c66768a00656e6143d364', '606741009919509661621760021348', 25, 4);
t('0x32f102da079f77cac41', '15035262184397547023425', 19, 4);
t('0xa440f8912c06198b', '11835733123122207115', 16, 4);
t('0xc008c78c61addc8e085ca3ff6e76fa13', '255257360887256236558111057213476239891', 32, 4);
t('0x11649c762', '4668901218', 9, 4);
t('0x5572f75ca5f099eda', '98516089885791198938', 17, 4);
t('0xaf', '175', 2, 4);
t('0xc41a62e8bd1c7123c92220df', '60690961081480451125474894047', 24, 4);
t('0x765e3e05ca0c4b853679e80667d71bb51ec118c87c1', '2767923543808337676781898227256098432891809077954497', 43, 4);
t('0x643b91b0289fe98c02b3f790ed41085ba228ba4c', '572227512274253374435718937361849836268824345164', 40, 4);
t('0x12', '18', 2, 4);
t('0x28ea59cbb990457243147551fc12145', '3399121160718415003848736585359106373', 31, 4);
t('0x1c149ecb87796c6a9116eaa5', '8690508679745247747029527205', 24, 4);
t('0x3d24cfd5a3d86612', '4405874851959039506', 16, 4);
t('0x55', '85', 2, 4);
t('0x2b1dc5d2236fc61848eb80e4032e842131c7ea1edd0', '1008232683040405259975519873135905613349630326730192', 43, 4);
t('0x3591a1d0aaaa14514d8a0a8826ee', '1086505871907198290436180679337710', 28, 4);
t('0x1cba2a2f26dfe80b4c05d5f5496b9', '9322511400054499645799889634629305', 29, 4);
t('0xdd2f83', '14495619', 6, 4);
t('0x15c6f07', '22834951', 7, 4);
t('0x2f8f19d0d3ff', '52291659944959', 12, 4);
t('0x66877666510', '7045749564688', 11, 4);
t('0x153d9792e5b2bd96679de7bbee9f34cd131', '115644794069417523805676707579411471061297', 35, 4);
t('0x1f6ce9be57023fe14fa060be4c01e7a', '2610723550735662335298250928784678522', 31, 4);
t('0x9e63632c0dca5485e48bee9ad1b5a28049aa157e307', '3703754566336033126591165191492065433661004773319431', 43, 4);
t('0x8371b0d9c54b9de08c7', '38795452173112617863367', 19, 4);
t('0xd3b35e07218e7b0c20bfc', '15995649127931990167915516', 21, 4);
t('0xc6b6dfbdc40011198bd286c0', '61499113032079803212142642880', 24, 4);
t('0x7cf9a45c21858e891798ad503930df741b93f61f127', '2922422513262668930583564242609727203228735133315367', 43, 4);
t('0x678049c017727c47ff4cc7ba35a849365fd111', '2308152223994224783375970725248611287908208913', 38, 4);
t('0x72b397d', '120273277', 7, 4);
t('0xf9445c1a', '4182006810', 8, 4);
t('0x4aff51f382c09c710fc5302d96b22', '24338029676537462451324711222209314', 29, 4);
t('0x10459598a086ea0f535900e70abab1e2ce7377', '362873575854611890806983645493404163992613751', 38, 4);
t('0x13640c20a010754124', '357697310375837778212', 18, 4);
t('0x14147e01ca6501f252ca', '94825344299726024102602', 20, 4);
t('0x466', '1126', 3, 4);
t('0x74c698493dd81930c415', '551457940709438745789461', 20, 4);
t('0x2e5f2b623ba0cfee63689d427bad6eb6be5', '252471852786048400736119714699808445524965', 35, 4);
t('0x38a52cc273671b0b8b078ec7f7f17102c9bd8c', '1263230489190036409842245570352830262209527180', 38, 4);
t('0x78655d620287e6db76141a906c5701bdc47', '655497934873142286500331809443840511433799', 35, 4);
t('0x6eecb9a0d2fdd3b9a541f3', '134099742883823958727410163', 22, 4);
t('0x54bd61680d7ceb5beb37894e46599ef77', '1802215542237292717156325458542562242423', 33, 4);
t('0x3a847dfcee83cd860720c8c0d8b53c7fda25d77', '20879758636120455697847204680129815020870720887', 39, 4);
t('0x76eb310380a6f577f166b90d28c3b107a', '2529121398079147937688504401561827086458', 33, 4);
t('0xb73dda2c', '3074284076', 8, 4);
t('0x3fd278b8d795a', '1122771216988506', 13, 4);
t('0x778da0c24f47774967183e20f8b1827299f', '650909720313013143267150228395755917748639', 35, 4);
t('0x6500d', '413709', 5, 4);
t('0x5a1bf29425c38c8f22a81fc3f105169ce4907acbb7', '131694699796400245476746024523885969905255483886519', 42, 4);
t('0x1e946da5ed27825dff2', '9025563349429600509938', 19, 4);
t('0x23d288aea4', '153856028324', 10, 4);
t('0x4bdc3b2b93e8cb0967b92', '5731840537208636428417938', 21, 4);
t('0x1c57b1', '1857457', 6, 4);
t('0xb6dab6e4caceab483d2085d9d1766a088a19', '15928860703021466826033711809396661962705433', 36, 4);
t('0x3c9e2c9d', '1016999069', 8, 4);
t('0x2d047117ed235996e16cb8', '54422637554743220665150648', 22, 4);
t('0xdda0ed04ef2e2b22a78e6455b862865ce', '4713519390205494839540473117533526320590', 33, 4);
t('0xa', '10', 1, 4);
t('0x984e5039808eb14e793dd95', '2946024784801310608062668181', 23, 4);
t('0x18b', '395', 3, 4);
t('0x1e30c76d4c3babeded1eb9d54', '149496328017603561036003908948', 25, 4);
t('0x4d1fb3fde8905', '1356776945387781', 13, 4);
t('0x1c6ad164b71af7cf0a92d7c2cf97ac3539cf4a190a6', '664509895940083432745213666480332815238360970924198', 43, 4);
t('0x29d730cd9c087e9', '188433258449504233', 15, 4);
t('0x4bbffc982422401d23e107db16617c0c0', '1611023225678920504550274579287300882624', 33, 4);
t('0x34fa796a05fee3b566107aef6fea5327c9f794ce6f2', '1238848647360391370812154035309938766206217768199922', 43, 4);
t('0x2907465cdd296accc8ab4bd', '793605010131443253911401661', 23, 4);
t('0x8aa7eb5be50', '9528363302480', 11, 4);
t('0x15c14f12e032624a1206', '102735615609474072056326', 20, 4);
t('0x2d2650f939302bf9306f3db1fd19a7666712ff8', '16109941674613560268665251639244419228113121272', 39, 4);
t('0xc0b42d10550ce0f4ea97567ede6bae89e93b', '16786869625005321512335207434991310677338427', 36, 4);
t('0xbcb3750ecd418048f3c9a907a1', '14950433883660044294408311998369', 26, 4);
t('0x5dd205e2db781f491bff', '443054323304979904404479', 20, 4);
t('0x3', '3', 1, 4);
t('0x108ba7dc0b83574862fffc703b989d5b578d862', '5903642409059499044928754369694490849414010978', 39, 4);
t('0x464a1', '287905', 5, 4);
t('0x172f', '5935', 4, 4);
t('0x3da62e0cd7d5edc8b6731fc', '1192467796933113553619464700', 23, 4);
t('0x16077c0833e289da0b', '406367684695924791819', 18, 4);
t('0x784c5768a01120f03ef7a73160baaa0c5f', '40935359210071367599328032328982052080735', 34, 4);
t('0x3ba90bcf292a852be', '68783684858858197694', 17, 4);
t('0x481df814c99e917079aeb', '5449011495668093676919531', 21, 4);
t('0xd14f6c28f6b1a66f83ec00058d939e6deae057', '4667774422027164788903448529246588503172243543', 38, 4);
t('0x36818425f9ca90bbe7a5b983c074', '1105511449492687971454561936457844', 28, 4);
t('0x2c977359c619b2a50e368272a2e12faa4', '948358531678320636918207632756786264740', 33, 4);
t('0x6786f6aaa24466c66772096948176f023b4ee4267e3', '2420882788095960105392950361690122210695410931099619', 43, 4);
t('0x468dd654d147', '77575000215879', 12, 4);
t('0x466d816c1a1', '4839758545313', 11, 4);
t('0xd6bcf011b9965', '3777711518226789', 13, 4);
t('0xcbd3b0dd08123466b52d', '962545403373485503722797', 20, 4);
t('0x41ea3b163a5614966ae7957bde8126e0a93d4a4', '23519245104289372491020812621093511206089774244', 39, 4);
t('0x3d42f8df046ed6958fc5b33d9fa992b492f1e', '85386222153107555893245630091838241326575390', 37, 4);
t('0xfba75c3e2c8a777f', '18133563846735591295', 16, 4);
t('0x6a7f74151fcc6ed8ed2b3f19100', '135002082526570912993917396947200', 27, 4);
t('0x5a0d410c996ff91fce14753b986e36ed02c8038a', '514104745647653703895348991238314574953430123402', 40, 4);
t('0x98ef2d49bef8f926076d15ea07db47db', '203284532859688206391148792201594226651', 32, 4);
t('0x1ed53c612a9ce8f563380bc006af575169', '10491910079311728745430929182060466098537', 34, 4);
t('0x11c25b068603cce9f3bbdca', '343512914478456071211695562', 23, 4);
t('0x772a8e4b457995e13897900d8000ad6c1f7c9a1', '42519933036531441133313813110786358673933846945', 39, 4);
t('0x1d1cd508f519156', '131111610056020310', 15, 4);
t('0x5da9a9bf96be6918e50', '27644363394761964490320', 19, 4);
t('0x14a08119381f59538f02a2c549605', '6693834434076143282016415621879301', 29, 4);
t('0x598e03f8e19f4379c5b70b9c15f4fa9156bcdf74116', '2094150575916241308211940593568291573516182910091542', 43, 4);
t('0x355b5738c3cfe719582f351c17af6b629d4', '290502049209306091381681583617785118206420', 35, 4);
t('0x15a243c6d249', '23786665988681', 12, 4);
t('0x3a9e2ecf094bcff872507503010fcbac11', '19946638349599244406026473172687735467025', 34, 4);
t('0x2b0142e2bc8feaa4657563be6095f30f9f787e6', '15344670653497010702533663436850880847648622566', 39, 4);
t('0x249c44f17568b404f004d1fab5d14', '11880762815518784994450284839918868', 29, 4);
t('0x5496b049593863de8ab664bcf192d8aa3046b16', '30182230828157060898612488525177295598317234966', 39, 4);
t('0x3308c774d7a9d93620db30a6dc7c3afb6245cda884b8', '19094196084927690615894155917265930659289199085651128', 44, 4);
t('0xe1aebc286f28a4213d5b89774ba1b2c', '18748973437595317918722188262730505004', 31, 4);
t('0x16fceb35ec78f61b7', '26503318076778308023', 17, 4);
t('0x1e', '30', 2, 4);
t('0x802a2fb0ef85471', '577202901428491377', 15, 4);
t('0x22905c', '2265180', 6, 4);
t('0x1933e587c735a0944325aec2059cbfc7447e', '2195466647218532976318479234926892387091582', 36, 4);
t('0xdcb0', '56496', 4, 4);
t('0x86aee9b70c52fb93dea1ce85e', '666919169547294519852185479262', 25, 4);
t('0x396769e718f39e316d00bcdc49721c228ea3', '5000590150769401690668401759809188422389411', 36, 4);
t('0xad7b683e1fc7cdea2dd3fda24f96f6ce5022803f0dd', '4056709020997348015695058837718936633645982841827549', 43, 4);
t('0x325bd1', '3300305', 6, 4);
t('0x3bace918a9ac3ab0e2c9d64', '1154290724173228330560822628', 23, 4);
t('0x2a549e1fc1c63f027e4af4879d42e41d2c', '14404335589336084186051447276771435879724', 34, 4);
t('0x6f0cfb185fd93b13bfe1', '524422133844304697999329', 20, 4);
t('0x1ed471cbb25831d740fad016d1d3b092756e7', '42970555202513419911347877108629841551775463', 37, 4);
t('0xf974bd83', '4185177475', 8, 4);
t('0x7f6d06d941b729ee41ec06af76ce5284c2', '43360782010770292902695704345624074945730', 34, 4);
t('0x52b6d2313c32bd8b492b829f096003bab3ae2af0afb', '1934189728430433084118852318011260708451697369746171', 43, 4);
t('0x109589b891295cc8f907838a8ff1a1a8d085d9b5e4c', '387803793636734915816188347290438110144007551802956', 43, 4);
t('0xad9a3ee51ae483bc3c92ee9719ed', '3521077463500554185208755094231533', 28, 4);
t('0xf3f77b3b2e9b8c8ac86ff', '18433604493853855199299327', 21, 4);
t('0x26d3525', '40711461', 7, 4);
t('0x38b954141f26f2a4afe6f7a9b5e34286428e3', '79061632155013935902994702509288944969197795', 37, 4);
t('0x38240bedb839f71c66a', '16569841585813541996138', 19, 4);
t('0x7518019e9f1b02abec44d0b94eb31e2641e59f76b', '10695796466552661793442196497637299434594286303083', 41, 4);
t('0x3fa622c7ed221182e769dd30636092d163', '21658621556399738720046392793916662534499', 34, 4);
t('0x789b534735', '518002001717', 10, 4);
t('0x3a53c2755b1260d232bb8d62729689f9aeb62e35f60e', '21822791108317911324343501911275861646156768606549518', 44, 4);
t('0x5337ac5ca7b7ee1c', '5996450942817922588', 16, 4);
t('0x157b2e3d04dc2d3f2c5d24471f4ea6e', '1784586140646675991730453110223858286', 31, 4);
t('0x1efcc47a12967085ad8cf3e4bd18a9d6', '41189283705768995637851264202925713878', 32, 4);
t('0x1889b9fe35e07e831ee8', '115877401735749106343656', 20, 4);
t('0x7526131ba0fe6e6d338a003af179d', '38016936118707892590533223274977181', 29, 4);
t('0x1ea4cb38dc109662aff507', '37045991477844459182355719', 22, 4);
t('0x16166f015f2938', '6217115507829048', 14, 4);
t('0x5f550f99', '1599410073', 8, 4);
t('0x1a12b67c34d57d7b7ab7bac0', '8069232682011269556707244736', 24, 4);
t('0x23310db646fa85615a6d3a159621607b', '46777680511357499186246331786523140219', 32, 4);
t('0xdf', '223', 2, 4);
t('0x1f000932fa1ca86508eaafa96ab453c29', '659300071197325571806191735253210840105', 33, 4);
t('0x35ec5ce3922a7b1370', '994709174014332048240', 18, 4);
t('0xe77b7374944b', '254517404013643', 12, 4);
t('0x1d0f1645dc1656b1174ce08b54fe4e40d8a45a3', '10368573985886829358840965263279576467697714595', 39, 4);
t('0xef557cf221b976840f876d6fb8f40', '77668303327151794801661259781214016', 29, 4);
t('0x11d071e8c8ed7f60c4fce894fa20a754', '23679184030321848843326203235370313556', 32, 4);
t('0x7cee134a1dab3d5cff44b067e971', '2533881063347006744885016016710001', 28, 4);
t('0x2fc6363ce8caa6f2f7d7dc022c', '3785067239745545603746923020844', 26, 4);
t('0x3bf5488fde2e', '65924670414382', 12, 4);
t('0x5661a43808fca8b4914', '25495292807490092878100', 19, 4);
t('0x25ad8a6e4382e566', '2714978356557964646', 16, 4);
t('0x43906e3351853cb2ad062c9315091712290', '367854393737791193668837913203410675507856', 35, 4);
t('0xecd7559017ec', '260409597630444', 12, 4);
t('0x393b9b61ad34', '62928172723508', 12, 4);
t('0x31b7ebb7e8b136deb2b30b4593ad1a775e7', '270692937955729861614382230692061625415143', 35, 4);
t('0x31c49f4d6a14d5a60e3be92b6c7d09a28ef733', '1109864730568327689119301182815368410691467059', 38, 4);
t('0x2ce42c8496', '192806683798', 10, 4);
t('0x3abd', '15037', 4, 4);
t('0xaa954cd38c39006a0d5d65a0b2', '13514993771256587973240014872754', 26, 4);
t('0x6f8a84d', '116959309', 7, 4);
t('0x5ab9da880303', '99754281796355', 12, 4);
t('0x8273c422025895e75c', '2406418559385510209372', 18, 4);
t('0x476bd81afce52', '1256456203521618', 13, 4);
t('0x84c5f2554693b9f5500f5bb85b158fde13e1f', '185058871763639409971122557584749513555394079', 37, 4);
t('0x7705c09763f0c8', '33501846960337096', 14, 4);
t('0x514fb06b03ae4e191f9375228e62', '1649188801468585902988396540890722', 28, 4);
t('0x1fc020c94aec1d384d6939fc0b55b6275a201238e6', '46403408144166737594428754848567058468276133837030', 42, 4);
t('0xef3608f1c4e83', '4208245717356163', 13, 4);
t('0x1acb8e8c35bb51f0a97f', '126536489245502589675903', 20, 4);
t('0x117eacbdcefdf0a6a17f2fff826d4a3757e9a72', '6242361556294202529040777632205572383849749106', 39, 4);
t('0x1725ab', '1516971', 6, 4);
t('0xdee149', '14606665', 6, 4);
t('0x278cbbef4c3b7a5cd3ae71e1', '12240052494575754714578579937', 24, 4);
t('0x2570b2cd172507d801138abed2', '2966320491435734983427362569938', 26, 4);
t('0x7a61cd850ab00f4e75b8fdd', '2367212971376424991309139933', 23, 4);
t('0x1c46b1c9ef8122e5c0809', '2136485514231402911762441', 21, 4);
t('0x159a345bdf44d369a', '24905827046438811290', 17, 4);
t('0x7dd0aa8c145447eb92707ad1d07', '159489590003544512404938984070407', 27, 4);
t('0x24b44822469ba933aa9cc564a0b792345', '780612549310309792407655025164475245381', 33, 4);
t('0x3a670f32d8a0d0c5fe1d860669e0fa790a28', '5087581870263472260351886848536796076771880', 36, 4);
t('0x2413dcab4dd4acf50d555c028f9dfa7', '2997208574424073828351508066743213991', 31, 4);
t('0x339ef7a5f81e079987fa8c3ae71', '65437348931585993956193860824689', 27, 4);
t('0x15d1fe6b5dfe7e1a87573a3946b42cb4437be39c6', '1993149199833169001344544884949567309662274861510', 41, 4);
t('0x7672ff747c781c06ec82bf84418073cc9158fdb', '42264090573810039509111928267687533762028343259', 39, 4);
t('0x66d1', '26321', 4, 4);
t('0x1487132dabd4006942ea4621e5753f54520400535ef3', '7680300593500415724655977000547063327920546737512179', 44, 4);
t('0x8ca', '2250', 3, 4);
t('0xab32097dd97de47c4f76930046f32a1', '14222362164666534040463596276719497889', 31, 4);
t('0x198c811986971ccf4c7ae1d257bd14617', '543363838528230108444050115794098538007', 33, 4);
t('0x3434042fa72b6bd086b5f583063b090b', '69389940122557978795038540059404601611', 32, 4);
t('0x5180a950fe82c6376276a586c25b5c5c5b4bb8a21e0e', '30493736786942864405814520647491453938628818133720590', 44, 4);
t('0x6e1b6e52c50', '7566505880656', 11, 4);
t('0x977a3cf2b2f06c31b3d', '44708264591227581831997', 19, 4);
t('0x238d459b304a504cc07bde524ffcae', '184595724574603234807440528928406702', 30, 4);
t('0x2951804f7cc040bcabed937dfc07518ebf0c31156972', '15459035341493840021436449671050677487751991559285106', 44, 4);
t('0x2b0a983ec857ac84ef5f', '203257196630153042915167', 20, 4);
t('0x44ebf64ca6d7048632dc366985bacf6ca72f55bb89cb3', '412586872136786946015831424411703662517991501351918771', 45, 4);
// Floats.
t('0x75bcd15.e06522c47b19a6c5263a515f9917be8d99dc09ac', '123456789.87654321', 47, 4);
t('-0x0.000002123e2ccefcf5e755beec5961bda3d5a3b9', '-0.000000123456789', 35, 4);
t('0x3e7.ffbe76c8b4395810624dd2f1a9fbe76c8b439581', '999.999', 43, 4);
t('-0x1f846105.402bf1f5be1e92bd2fdbdca317fa561bb1faaa3c', '-528769285.2506705498654986754987694357629487612132293856', 48, 4);
t('0x4e8ba596e760723db17586b2141fce3b37f803587c2c09a7f054e80000000000000000000000', '9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999.999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999', 76, 4);
t('0x8781fe7e4176fc66a66ca5730090c7', '703596669768604729463688604501971142.9176994711280241981325903319', 30, 4);
// Include binary exponent.
t = function (expected, n, sd, rm) {
T.assertEqual(expected, new Decimal(n).toHex(sd, rm));
}
t('0x0p+0', '0', 40, 4);
t('0x1p+53', '9007199254740992', 40, 4);
t('0x1.8p+8', '384', 40, 4);
t('0x1p+1', '2', 40, 4);
t('0x1p+8', '256', 40, 4);
t('0x1p-6', '0.015625', 40, 4);
t('0x1.b7p-1', '0.857421875', 40, 4);
t('0x1.999999999999ap-4', '0x1.999999999999ap-4', 14, 1);
t('0x1.921fb4d12d84ap+1', '3.1415926', 14, 4);
t('0x1.5b23a8dd37fc2p-10', '0.001324231321', 14, 4);
t('0x1.81016cc52538ap+9', '770.0111319', 14, 4);
T.stop();
})();

93
test/modules/toJSON.js Normal file
View File

@ -0,0 +1,93 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toJSON');
function t(n, expected) {
T.assertEqual(expected, new Decimal(n).toJSON());
}
Decimal.config({
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
// Base 88
// 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^_`{|}~
// 0 0 g 16 w 32 M 48 $ 64 ] 80
// 1 1 h 17 x 33 N 49 % 65 ^ 81
// 2 2 i 18 y 34 O 50 ( 66 _ 82
// 3 3 j 19 z 35 P 51 ) 67 ` 83
// 4 4 k 20 A 36 Q 52 * 68 { 84
// 5 5 l 21 B 37 R 53 + 69 | 85
// 6 6 m 22 C 38 S 54 , 70 } 86
// 7 7 n 23 D 39 T 55 - 71 ~ 87
// 8 8 o 24 E 40 U 56 . 72
// 9 9 p 25 F 41 V 57 / 73
// a 10 q 26 G 42 W 58 : 74
// b 11 r 27 H 43 X 59 ; 75
// c 12 s 28 I 44 Y 60 = 76
// d 13 t 29 J 45 Z 61 ? 77
// e 14 u 30 K 46 ! 62 @ 78
// f 15 v 31 L 47 # 63 [ 79
// 0123456789abcdefghijklmnopqrstuvwxyzABCDE [0, 40]
// FGHIJKLMNOPQRSTUVWXYZ!#$%()*+,-./:;=?@[]^ [-0, -40]
// _ 82 -Infinity
// ` 83 Infinity
// { 84 NaN
// | 85
// } 86
// ~ 87
t('-40', '^');
t('-1', 'G');
t('-0', 'F');
t('0', '0');
t('1', '1');
t('15', 'f');
t('40', 'E');
t('-Infinity', '_');
t('Infinity', '`');
t('NaN', '{');
t('-41', 'w0');
t('41', '00');
t('-2856', '#~');
t('2856', 'v~');
t('0.1', ',1');
t('0.01', '+1');
t('0.001', '*1');
t('0.0001', ')1');
t('1', '1');
t('10', 'a');
t('100', '0X');
t('1000', 'a[');
t('1.5', '-f');
t('123456789.87654321', '[3C7]NAda1');
t('1234567890000.0000000987654321', '1c7yH67}?[lk2mc:%');
t('-0.1', '_1');
t('-0.01', '^1');
t('-0.001', ']1');
t('-0.0001', 'N41');
t('-1', 'G');
t('-10', 'P');
t('-100', 'wX');
t('-1000', 'G[');
t('-1.5', '`f');
t('-123456789.87654321', 'x83C7]NAda1');
t('-1234567890000.0000000987654321', 'xc7yH67}?[lk2mc:%');
t('0.00000009876543212345678987654321', 'h8J+]nxS}gN-^oN');
t('-0.00000009876543212345678987654321', 'N8J+]nxS}gN-^oN');
t('1.00000009876543212345678987654321', '-7$yQ@UAPUk2SZ#XQh');
T.stop();
})();

157
test/modules/toNearest.js Normal file
View File

@ -0,0 +1,157 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toNearest');
function isMinusZero(n) {
return n.isZero() && n.isNegative();
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
var t = function (actual) {
T.assert(actual);
}
t(!isMinusZero(new Decimal(0).toNearest(0)));
t( isMinusZero(new Decimal(-1).toNearest(0)));
t( isMinusZero(new Decimal(-0).toNearest(0)));
t(!isMinusZero(new Decimal(1).toNearest(0)));
t(!isMinusZero(new Decimal(1).toNearest(-0)));
t(!isMinusZero(new Decimal(1).toNearest(-3)));
t( isMinusZero(new Decimal(-1).toNearest(-3)));
t = function (expected, n, v, sd, rm) {
if (sd) Decimal.precision = sd;
T.assertEqual(expected, new Decimal(n).toNearest(v, rm).valueOf());
}
t('Infinity', Infinity);
t('-Infinity', -Infinity);
t('NaN', NaN);
t('NaN', NaN, NaN);
t('NaN', NaN, Infinity);
t('NaN', NaN, -Infinity);
t('NaN', NaN, 0);
t('NaN', NaN, -0);
t('Infinity', '9.999e+9000000000000000', '1e+9000000000000001');
t('Infinity', '9.999e+9000000000000000', '-1e+9000000000000001');
t('-Infinity', '-9.999e+9000000000000000', '1e+9000000000000001');
t('-Infinity', '-9.999e+9000000000000000', '-1e+9000000000000001');
t('9.999e+9000000000000000', '9.999e+9000000000000000');
t('-9.999e+9000000000000000', '-9.999e+9000000000000000');
t('NaN', 123.456, NaN);
t('Infinity', 123.456, Infinity);
t('Infinity', 123.456, -Infinity);
t('0', 123.456, 0);
t('0', 123.456, '-0');
t('NaN', -123.456, NaN);
t('-Infinity', -123.456, Infinity);
t('-Infinity', -123.456, -Infinity);
t('-0', -123.456, '-0');
t('0', 0, 0);
t('Infinity', 0, Infinity);
t('Infinity', 0, -Infinity);
t('-Infinity', -0, Infinity);
t('-Infinity', -0, -Infinity);
t('0', 1, -3);
t('-0', -1, -3);
t('3', 1.5, -3, 20, 0);
t('-0', -1.5, -3, 20, 1);
t('-3', -1.5, -3, 20, 2);
t('123', 123.456);
t('123', 123.456, 1);
t('123.5', 123.456, 0.1);
t('123.46', 123.456, 0.01);
t('123.456', 123.456, 0.001);
t('123', 123.456, -1);
t('123.5', 123.456, -0.1);
t('123.46', 123.456, -0.01);
t('123.456', 123.456, -0.001);
t('124', 123.456, '-2');
t('123.4', 123.456, '-0.2');
t('123.46', 123.456, '-0.02');
t('123.456', 123.456, '-0.002');
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', void 0, 30, 0);
t('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 1);
t('83105511539', '83105511539.499999999999999999999999999999', void 0, 30, 2);
t('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 3);
t('83105511539', '83105511539.499999999999999999999999999999', void 0, 30, 4);
t('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 5);
t('83105511539', '83105511539.499999999999999999999999999999', void 0, 30, 6);
t('83105511539', '83105511539.499999999999999999999999999999', 1, 30, 7);
t('83105511539', '83105511539.499999999999999999999999999999', void 0, 30, 8);
t('83105511540', '83105511539.5000000000000000000001', void 0, 30, 0);
t('83105511540', '83105511539.5000000000000000000001', 1, 30, 1);
t('83105511540', '83105511539.5000000000000000000001', void 0, 30, 2);
t('83105511540', '83105511539.5000000000000000000001', 1, 30, 3);
t('83105511540', '83105511539.5000000000000000000001', void 0, 30, 4);
t('83105511540', '83105511539.5000000000000000000001', 1, 30, 5);
t('83105511540', '83105511539.5000000000000000000001', void 0, 30, 6);
t('83105511540', '83105511539.5000000000000000000001', 1, 30, 7);
t('83105511540', '83105511539.5000000000000000000001', void 0, 30, 8);
Decimal.rounding = 0;
t('83105511540', '83105511539.5', void 0, 11);
Decimal.rounding = 1;
t('83105511539', '83105511539.5', void 0, 11);
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);
T.stop();
})();

80
test/modules/toNumber.js Normal file
View File

@ -0,0 +1,80 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toNumber');
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -7,
toExpPos: 21,
minE: -9e15,
maxE: 9e15
});
// Positive zero
var t = function (n) {
T.assert(1 / new Decimal(n).toNumber() === Infinity);
}
t('0');
t('0.0');
t('0.000000000000');
t('0e+0');
t('0e-0');
t('1e-9000000000000000')
// Negative zero
t = function (n) {
T.assert(1 / new Decimal(n).toNumber() === -Infinity);
}
t('-0');
t('-0.0');
t('-0.000000000000');
t('-0e+0');
t('-0e-0');
t('-1e-9000000000000000')
t = function (n, expected) {
T.assertEqual(expected, new Decimal(n).toNumber());
}
t(Infinity, 1 / 0);
t('Infinity', 1 / 0);
t(-Infinity, -1 / 0);
t('-Infinity', -1 / 0);
t(NaN, NaN);
t('NaN', NaN);
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('123.456789876543', 123.456789876543);
t('-123.456789876543', -123.456789876543);
t('1.1102230246251565e-16', 1.1102230246251565e-16);
t('-1.1102230246251565e-16', -1.1102230246251565e-16);
t('9007199254740991', 9007199254740991);
t('-9007199254740991', -9007199254740991);
t('5e-324', 5e-324);
t('1.7976931348623157e+308', 1.7976931348623157e+308);
t('9.999999e+9000000000000000', 1 / 0);
t('-9.999999e+9000000000000000', -1 / 0);
t('1e-9000000000000000', 0);
t('-1e-9000000000000000', -0);
T.stop();
})();

328
test/modules/toOctal.js Normal file
View File

@ -0,0 +1,328 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toOctal');
var t = function (expected, n, sd, rm) {
Decimal.precision = sd;
Decimal.rounding = rm;
T.assertEqual(expected, new Decimal(n).toOctal());
}
Decimal.config({
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('NaN', NaN, 20, 4);
t('NaN', 'NaN', 20, 4);
t('Infinity', Infinity, 20, 4);
t('-Infinity', -Infinity, 20, 4);
t('Infinity', 'Infinity', 20, 4);
t('-Infinity', '-Infinity', 20, 4);
// Integers
t('0o0', '0', 1, 4);
t('0o171634571716400543513334300705612071133717535572246575453160', '364584667335183828987221775272570428237696628507956848', 60, 4);
t('0o17140110747560', '1043696177008', 14, 4);
t('0o1656', '942', 4, 4);
t('0o642677755550042022420042650122720673705371422153432', '9341223088519577080757976073309527669316572954', 51, 4);
t('0o1651372117475740354637456547', '4427164671782016593583463', 28, 4);
t('0o432', '282', 3, 4);
t('0o1156036607174723020034543345673164620146641', '103357460209213083948351046056291650977', 43, 4);
t('0o347175', '118397', 6, 4);
t('0o250711224523642463565466455623', '408358568053857594342267795', 30, 4);
t('0o31464741215652662410302172736', '61905218854453628692395486', 29, 4);
t('0o1151171074647051031165674252760067', '764101851531641191689328779319', 34, 4);
t('0o111627132417321114752432320745434507337525667340540534056666', '220880699124044497678574383774865426395965086166441398', 60, 4);
t('0o66607051535464671602731746325356021372265', '9099202145653789818834446363266512053', 41, 4);
t('0o472035076601272777773466260770745221025541771310455547267433', '940021031620376267748547570264155096359926520862306075', 60, 4);
t('0o35100215607256233370100157131103657413347736114726441', '332554887108209374458014391052845453182019808545', 53, 4);
t('0o722062570016143', '32030085618787', 15, 4);
t('0o74663674130162363012065031725670307006351247702', '2650448086139415170144453379569169365028802', 47, 4);
t('0o221016156567502', '9966232203074', 15, 4);
t('0o761570133215525640271', '8966391655604633785', 21, 4);
t('0o101530101442425775517477023774', '158785455373148008304355324', 30, 4);
t('0o374160464102717737077444644401061474361141636', '21456498302081433312710883059235111093150', 45, 4);
t('0o31342760667031767334646421766116726252335314714', '1108212082493888677367272229520408961194444', 47, 4);
t('0o272343723733570133550665013', '880462300728651545799179', 27, 4);
t('0o27330316426437424646561612652414263301414200342717', '522342837272716004737400194551917026620851663', 50, 4);
t('0o33', '27', 2, 4);
t('0o6410235531675374505654365627', '15755268886904815024728983', 28, 4);
t('0o462207311743', '41106117603', 12, 4);
t('0o35434021473746', '2030987278310', 14, 4);
t('0o10766710063735420744724674434722341532775011206477', '200309946175742618027595387139557376886377791', 50, 4);
t('0o264652754111247167745300734100146216146065', '30046186741840723600384513771105209397', 42, 4);
t('0o1717051362601647', '67007056380839', 16, 4);
t('0o420547635403', '36601543427', 12, 4);
t('0o113650166605747526017701737745742053073656134564465203303', '443294363845688739540957905727674168806539626088131', 57, 4);
t('0o1403535540244734200354', '13901404808061976812', 22, 4);
t('0o74712131706533505237435313', '287567912644119793384139', 26, 4);
t('0o5136777371700436', '182450142019870', 16, 4);
t('0o2035677377165', '141448576629', 13, 4);
t('0o271106223317652510470133141417013436324344447232', '8063865882119118770028661617297344888458906', 48, 4);
t('0o1021722', '271314', 7, 4);
t('0o7036036165443146', '248356246275686', 16, 4);
t('0o6470565', '1732981', 7, 4);
t('0o61216176216205012773031', '454507717401133184537', 23, 4);
t('0o3002513066606060620347136440362562046653642', '255651532540391785253392875614499461026', 43, 4);
t('0o456', '302', 3, 4);
t('0o17065041017173527170644622577111123272557633404173157515', '88295987850015910722625103099562923405439709011789', 56, 4);
t('0o16027026131232476667231251', '66325667775824613159593', 26, 4);
t('0o16625630637244103026266171376764352575040', '2457838121719672737744590760418408992', 41, 4);
t('0o1561736223610', '118371198856', 13, 4);
t('0o15056662412721204036161014', '61822867030969079620108', 26, 4);
t('0o3477263035715376447112210', '17112580757759444423816', 25, 4);
t('0o161037100117541', '7769478438753', 15, 4);
t('0o32556410147661251456104752223004', '33072622383942794561666491908', 32, 4);
t('0o1211474324420476530235671057512302', '804188130270400499435404432578', 34, 4);
t('0o36007574066667272553066076615170250031017703', '2553404178224213798051876650192088604611', 44, 4);
t('0o1237051', '343593', 7, 4);
t('0o366237621254212707310212730126632527636236606', '20953914213183846148388529652331213045126', 45, 4);
t('0o676337572246445153657', '8042293848523986863', 21, 4);
t('0o157423050242731427202356723', '526719833217016133180883', 27, 4);
t('0o7732111706233511415326631451', '19164044677656856523125545', 28, 4);
t('0o133574562456214335435', '1652705792533576477', 21, 4);
t('0o12151', '5225', 5, 4);
t('0o1372066706', '199781830', 10, 4);
t('0o37324076026320245555326737570636206', '19911177604481197795113399696518', 35, 4);
t('0o2436', '1310', 4, 4);
t('0o15576357436114241002422756773501074050', '4461159021738482150619844582864936', 38, 4);
t('0o25163361', '5564145', 8, 4);
t('0o563305225055677232242325342', '1753817655195311740136162', 27, 4);
t('0o1730611463642631260026156435013323236764317226', '83774860480485487711819613225974439714454', 46, 4);
t('0o3124144616475210442326726176753', '3917395568817125518374141419', 31, 4);
t('0o122551245377370372510600247650271544', '52420971115555265131642802500452', 36, 4);
t('0o711265667352525777055750103304054072', '289883291844318827546712512419898', 36, 4);
t('0o1424357303022501420341156201', '3723432687881212284689537', 28, 4);
t('0o51147130442424172652616112', '194568628606971297864778', 26, 4);
t('0o3427410030517411126776423004072314', '2247499600567123820908846806220', 34, 4);
t('0o16602427320624026652410144225431222411', '4788262207154170686928960302163209', 38, 4);
t('0o46144610334425521434631035561707752201423', '6346533567879985413095577825858618131', 41, 4);
t('0o1130215551', '157358953', 10, 4);
t('0o1214401', '334081', 7, 4);
t('0o222116623333265530440631564017304', '180929743300409204225159995076', 33, 4);
t('0o15567437201441347355454544146426241554605511544026607651', '80286234176563111847045853769570753921004267573161', 56, 4);
t('0o2254120142306727111645063565', '5648689955684980442294133', 28, 4);
t('0o203252000343611312345016732574324517652170570536340103164002', '393097177469022242668976094291182082270851391919286274', 60, 4);
t('0o22410502071700760126344737773405044556536263663106274741', '108249648375668138579864767958324372334698552719841', 56, 4);
t('0o702464247710160725611573536407615231642232', '74869132891027108059075932498363368602', 42, 4);
t('0o71215302120100471557063', '528279067564974726707', 23, 4);
t('0o3443452305237156410051107403', '8630515683508240645394179', 28, 4);
t('0o1750617616706657707114034617432306132573321272245040042711', '5850571219466548068012306893496891664635414265742793', 58, 4);
t('0o747373012741076272574334113131066623327', '158199639324663999178714767706236631', 39, 4);
t('0o240646541755015151746375314736543447343444475552143', '3586530035933343022858608741776409267984061539', 51, 4);
t('0o21345516652054242646357330536124', '21600249893595093431386029140', 32, 4);
t('0o3052066107', '413690951', 10, 4);
t('0o116', '78', 3, 4);
t('0o3050340627050765676451357427033162550', '999186955807785473462332939887976', 37, 4);
t('0o172013616177746634055145614015', '295033519224308286956705805', 30, 4);
t('0o161654155547445343476406063530377171044513302703466', '2538635569062190223060841428161267358214358838', 51, 4);
t('0o36173', '15483', 5, 4);
t('0o36547444550627731264507057423205012330760602245415526634143', '91896719045463903069060584567797070657705215769917539', 59, 4);
t('0o23020170177167056322724056253016211772161010110040067', '217303698775390775219268953665006962201726042167', 53, 4);
t('0o360364043226375763434734203', '1135619094464764138731651', 27, 4);
t('0o14233136655362371400640556051237407411322356356326214052664', '36825078122035846824139359498863387810994115321025972', 59, 4);
t('0o1640200513276356713203217', '8561606752326371837583', 25, 4);
t('0o6103526361624161311443517175371632412741737', '521666973443756820065064110478867547103', 43, 4);
t('0o174406316667406655013647151755454742463', '40406618960600991640852771818947891', 39, 4);
t('0o7641714202176443731750235267341521674705251706234', '174307282119711580494340594082900153247173788', 49, 4);
t('0o740202262443263067454211712735764360631542423775344744', '5483538014645444559676878691527370323481540807140', 54, 4);
t('0o352754440661731162345175142131150650044732105622163', '5239828571223832230977981455751540869256651891', 51, 4);
t('0o373127070001223103537740007213', '607292123862578721351274123', 30, 4);
t('0o37572601640375442622771540474365322704464564070', '1382461219874045756706531331920884785145912', 47, 4);
t('0o1442414261073074545327716347556337315543405616452064022', '9163205510581199876674535919032970590548216277010', 55, 4);
t('0o1637342435475173653242473', '8554147181574260344123', 25, 4);
t('0o537377662473314366627013423', '1659910424702725658515219', 27, 4);
t('0o3166512513354164277266524513220176106234611', '274925189339848199032955327991581849993', 43, 4);
t('0o64246753172171466452551711206021704632', '16980787914168592911515222526101914', 38, 4);
t('0o1325642', '371618', 7, 4);
t('0o172347572204054163707174', '1129426023321529454204', 24, 4);
t('0o1707337005035225145674', '17427769821173697468', 22, 4);
t('0o3167272', '847546', 7, 4);
t('0o2376477566636626564635', '23033650866571372957', 22, 4);
t('0o35417144376113077', '1038983257167423', 17, 4);
t('0o106327541747664237656046756411744551632275412233636062531656', '210781807562814008194311763577265460650228437440181166', 60, 4);
t('0o3763572416255254335772542046235033', '2520123204503077543365320456731', 34, 4);
t('0o75362616525327077427633563743155774', '38963888713731612415310433147900', 35, 4);
t('0o1401406016234566024656', '13862291742387612078', 22, 4);
t('0o242172304552', '21775354218', 12, 4);
t('0o10325355', '2206445', 8, 4);
t('0o5503607200750620360575714717560', '6972513910589491335440605040', 31, 4);
t('0o264701463721526107175255711722057442604571730762750705256542', '541396336231392418293871062570279037186171679825812834', 60, 4);
t('0o421625631535034357267563', '2525290811852796555123', 24, 4);
t('0o3766050301207656231423150647646364447', '1291785946520991837632125610879271', 37, 4);
t('0o1630720467054635751474753253627460422', '583694432446675939525765785084178', 37, 4);
t('0o303124303051000610137231406655066133635770174121', '8500626221290107216014710817942733884291153', 48, 4);
t('0o1113562110102132653505161654522056473771101354321312031', '6710609582342689120085581704302230873683253367833', 55, 4);
t('0o1464600512311275', '56401597141693', 16, 4);
t('0o35261605356', '3938913006', 11, 4);
t('0o120354645453413557275444611571627313424176417756144520333753', '240836899455748097083887093250256470467559683019356139', 60, 4);
t('0o6775333741557561774067363222030024220313353605226', '155993258459571709305776966445938258645813910', 49, 4);
t('0o1676422201112714661607652471073', '2317596989962208644778586683', 31, 4);
t('0o1453174752703234014531654704472633215271161761475347123730', '4742538088234854254854687216429269914428692374530008', 58, 4);
t('0o53154012227153364107323333356132334', '27388210321734783241567604356316', 35, 4);
t('0o35225503612770774201320011176174535217542332620333552', '334458377978261177426569028332297268603291547498', 53, 4);
t('0o414365504624046053220263710402064311', '170169261032326095162398418168009', 36, 4);
t('0o7456545364015236001000', '70016530198021276160', 22, 4);
t('0o13013306320776254', '387810637118636', 17, 4);
t('0o21', '17', 2, 4);
t('0o5347712744236105712406353', '25750698989482171567339', 25, 4);
t('0o4201033713624', '292199307156', 13, 4);
t('0o6147402214224431303026413646714237211640331341', '270142041873110958246056630570783242040033', 46, 4);
t('0o15240705643046435', '468452863921437', 17, 4);
t('0o3530013143266263651', '66147388776605609', 19, 4);
t('0o44672701365702351354627010564700332716441663244', '1605697031030267612185423502895189353522852', 47, 4);
t('0o3', '3', 1, 4);
t('0o6127516', '1617742', 7, 4);
t('0o66726644', '14396836', 8, 4);
t('0o5311555461504533675663441245372657173', '1750444240707415099769307901156987', 37, 4);
t('0o4054706260215077404512214064677061152506', '679180789158344428977587279718831430', 40, 4);
t('0o62246711201113702465222477417147602750116154310733', '1122306478377713902587095609358921499575161307', 50, 4);
t('0o4215475722134', '293885944924', 13, 4);
t('0o53746157770654301215760653406471005756045764305156', '980109855734296770512774083035337723940538990', 50, 4);
t('0o74411760251306275052060', '558193600905071580208', 23, 4);
t('0o577115015776462242165511716153070323513627023272', '16688555517189422187103917664151515791369914', 48, 4);
t('0o67', '55', 2, 4);
t('0o17465535030523', '1072356929875', 14, 4);
t('0o13317', '5839', 5, 4);
t('0o2734162636214', '201356688524', 13, 4);
t('0o514235610013374235501066012045440247061144570241', '14474060683475264437751372654279118864707745', 48, 4);
t('0o3534775621556047145137126527746324006765443367053164', '42036808204933511970427575795842368941701486196', 52, 4);
t('0o1371035220605170410066165577113314501175100', '126452315889789497901223436832123189824', 43, 4);
t('0o51450362621322470420', '749021597016944912', 20, 4);
t('0o4', '4', 1, 4);
t('0o41726045554731777722315562631262755462314641246551410413772', '101522180338987737728899908294640200607836241899165690', 59, 4);
t('0o3726520073102165257153311', '18508139224259054327497', 25, 4);
t('0o110233030106104754146604170637', '174817507453714537420747167', 30, 4);
t('0o34321447613754733467632640535662447106103006103436', '633549261053883686239613232774717922594031390', 50, 4);
t('0o33260652734712254347', '492610547748526311', 20, 4);
t('0o3652056541643012540022255', '18097097047518748877997', 25, 4);
t('0o2266675470606120531031640140307074715050044204', '102669173431008960637137393788268958468228', 46, 4);
t('0o1767255257', '266164911', 10, 4);
t('0o46121044606131213674', '687399603768989628', 20, 4);
t('0o44615', '18829', 5, 4);
t('0o1066551671032724130551075541344416006004545251', '48210079462363778492658888113295918811817', 46, 4);
t('0o661746213440700265725363254604246460427455151704051', '9677402829255135526689200426680775741960325161', 51, 4);
t('0o6175', '3197', 4, 4);
t('0o401151407274000477346136437000', '621886148896195273543007744', 30, 4);
t('0o3757440272647170475376331367246161235546703357147547454', '23196351263151106376071114036941254762538586787628', 55, 4);
t('0o1135', '605', 4, 4);
t('0o2175424561041415433353531757', '5428551387992052131083247', 28, 4);
t('0o52520357630643422', '1500865557120786', 17, 4);
t('0o453', '299', 3, 4);
t('0o20246731230644474456707331224171', '20210639089554274678470944889', 32, 4);
t('0o3000523151311', '206247350985', 13, 4);
t('0o113134637066412045754477071261275213637470', '12491631272411798853591088807340359480', 42, 4);
t('0o126052261312470627317166600322300777652073650715', '3749430734838772876224746985432540515357133', 48, 4);
t('0o44316700137250607462031357163634027001772445', '3096914367914270992782060024671299433765', 44, 4);
t('0o171215002356221063407', '2184703385532655367', 21, 4);
t('0o23721121', '5218897', 8, 4);
t('0o14734353322620206602545731', '61062963683852360010713', 26, 4);
t('0o475312075530063365616', '5717675808740207502', 21, 4);
t('0o77440275263665614314052136204775', '78687457933212079867651754493', 32, 4);
t('0o5261257577514510167240362153507501754265746731563', '119228114395905189012428590020540134015611763', 49, 4);
t('0o145203764627604366316134', '933938082134087015516', 24, 4);
t('0o300440712774126174401451236156067007573370014604', '8387356043080138295526316927827140067465604', 48, 4);
t('0o1332570322632', '98077615514', 13, 4);
t('0o3716217572065650441626246', '18430886692014464117926', 25, 4);
t('0o716521140', '121283168', 9, 4);
t('0o61226277150121532713772501031623101', '31243593013026976686003389408833', 35, 4);
t('0o727134513004332506', '16578205872928070', 18, 4);
t('0o1015752175345655', '36143524858797', 16, 4);
t('0o15366300702132404747410165', '63663188402072700457077', 26, 4);
t('0o2607400245312045520037132356700', '3422470520825634689242488256', 31, 4);
t('0o1', '1', 1, 4);
t('0o14232370256353054042511271041451307447', '3992139171064784961434159759593255', 38, 4);
t('0o2654', '1452', 4, 4);
t('0o43200420031713445212602476237542777011721017120532156', '402495698817091827248733349983795241261310588014', 53, 4);
t('0o1012373453302574', '35905333986684', 16, 4);
t('0o102052273401065267741403121062144257736511671', '5621698349102047273384509211278621447097', 45, 4);
t('0o2303355462020425243403060', '11247570692927310923312', 25, 4);
t('0o236571440705332620722731730', '749616319651624136717272', 27, 4);
t('0o1634023045115006652225404137572537300225444451056550315', '10550640276770088084077930237138652035960136192205', 55, 4);
t('0o226062710577641', '10314752130977', 15, 4);
t('0o104167430465731064510563526155446356705', '22143034232047918382504353520541125', 39, 4);
t('0o360474703465644142142614426374633517336173745433164557017', '1406659725135506145446652465678360390928078042488335', 57, 4);
t('0o1077226367', '150809847', 10, 4);
t('0o533412700560147364151506123351553042070455067164', '15136684942816823221295501833940390148075124', 48, 4);
t('0o47321211337', '5289349855', 11, 4);
t('0o33', '27', 2, 4);
t('0o3114060641760665307', '56720562441120455', 19, 4);
t('0o321544500711356560655140', '1934109172007933532768', 24, 4);
t('0o31553466646', '3450760614', 11, 4);
t('0o25427707303456416047670142267372377104250171470', '938489360691345858919636520999045373686584', 47, 4);
t('0o124405625444044364574470555231', '204335816074449425736587929', 30, 4);
t('0o7417670326016217030', '135666019698548248', 19, 4);
t('0o14624322306021144203510134', '60398430088699424182364', 26, 4);
t('0o1674442410', '250758408', 10, 4);
t('0o527635172', '90126970', 9, 4);
t('0o7141002130726144240353615134174321', '4556862540217805685823766591697', 34, 4);
t('0o7703554633327072657443651371706621271374', '1309663585734465506833205292089832188', 40, 4);
t('0o22777415000440655526', '342256872923028310', 20, 4);
t('0o3077216', '818830', 7, 4);
t('0o34243442230362323775450370', '133734900702608268611832', 26, 4);
t('0o770344133547754604246147776', '2382177288166020121939966', 27, 4);
t('0o523215407441303043220321763763461205763333647', '28862443771771851434414707295001265420199', 45, 4);
t('0o37102705430230406225007132550325075', '19731384956592254443851247364669', 35, 4);
t('0o26654765110654444621720', '210641979748604126160', 23, 4);
t('0o575257272', '99966650', 9, 4);
t('0o7207565613527210030', '130876365269176344', 19, 4);
t('0o60127615404142232301236257126373142705430101557417025270', '281610543490460264519467262765660796455848821664440', 56, 4);
t('0o11777165574076763721455', '92219848663426376493', 23, 4);
t('0o35576422324763736', '1046634462177246', 17, 4);
t('0o366255123122311123125', '4437634644479092309', 21, 4);
t('0o1231751346340466252606553475546101570554617315561125473', '7603872826618045742580005490971103946545668860731', 55, 4);
t('0o535563217273266762141100234605765502234', '113492301891561204235365568461833372', 39, 4);
t('0o1657330721157546300772313767037603015', '597965777884596169919754548479501', 37, 4);
t('0o701711416205015540454465462370167111721657451163343320', '5136876924230800291846439025619119075547100858064', 54, 4);
t('0o2', '2', 1, 4);
t('0o23044346313736', '1310562293726', 14, 4);
t('0o762722210536357403530500', '4601638793217664004416', 24, 4);
t('0o2243232540752434710611323210536463', '1469808842581774120550500842803', 34, 4);
t('0o6042532553115031666', '109306485388096438', 19, 4);
t('0o54750443750225316571406736430512671452166747632', '1958033248391176678532214751521115754712986', 47, 4);
t('0o42122277123352400676', '615387804455272894', 20, 4);
t('0o141671751106136325535453330430775232437321543', '8325279825157794222097655945192898667363', 45, 4);
t('0o7335121015337612327750625531460025777262', '1234844453153886969183275916721651378', 40, 4);
t('0o30', '24', 2, 4);
t('0o646633456716673131010714325300106141144242503123341513', '4827567010183340607788016828465978158946284585803', 54, 4);
t('0o34647345400115736740552300416234100512013623645', '1255594995624059221065714883120130755078053', 47, 4);
t('0o6460334362676710', '232026545028552', 16, 4);
t('0o106142331346752221011206', '647409104513791169158', 24, 4);
t('0o11262714046100646006', '168424020893715462', 20, 4);
t('0o310576032000120564437670443150', '485374511652821184626706024', 30, 4);
t('0o5', '5', 1, 4);
// Floats
t('0o726746425.7006244261075431515424461645053746213677', '123456789.87654321', 49, 4);
t('-0o0.0000000204437054635763657165267673054542', '-0.000000123456789', 33, 4);
t('0o1747.7773716662132071260101422335136152375747', '999.999', 44, 4);
t('-0o3741060405.2002576175337036445364576675624305775126', '-528769285.2506705498654986754987694357629487612132293856', 50, 4);
t('0o35076567745235671502.6773342626436061433365155137731076310010275236050103305437451411644055625324564421515511562', '524624822785241922.8738874407101262195488876445', 111, 4);
t('0o5605470434246053632363152113440650264426323520.33525466364076204553563061761202201336001507', '250925107172835956608925073908081234650960.4323', 90, 4);
t('0o2321136.6635426603020156550074200106655', '631390.850962999306313972719936135603917', 38, 4);
t('0o243.4465610031', '163.575626396226555033529183865411120656777021626883', 13, 4);
// Include binary exponent.
t = function (expected, n, sd, rm) {
T.assertEqual(expected, new Decimal(n).toOctal(sd, rm));
}
t('0o0p+0', '0', 40, 4);
t('0o1p+53', '9007199254740992', 40, 4);
t('0o1.4p+8', '384', 40, 4);
t('0o1p+1', '2', 40, 4);
t('0o1p+8', '256', 40, 4);
t('0o1p-6', '0.015625', 40, 4);
t('0o1.556p-1', '0.857421875', 40, 4);
t('0o1.777p-4', '0o1.777p-4', 4, 1);
T.stop();
})();

570
test/modules/toPrecision.js Normal file
View File

@ -0,0 +1,570 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toPrecision');
function t(expected, n, sd, rm) {
T.assertEqual(expected, new Decimal(n).toPrecision(sd, rm));
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 4,
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);
Decimal.rounding = 0;
t('1e+4', 9631.01, 1, 4);
t('1.0e+7', 9950095.87, 2, 4);
t('1e+1', '9.856839969', 1, 4);
t('1e+2', '97.504', 1, 4);
t('1e+5', 97802.6, 1, 4);
t('1e+1', 9.9617, 1, 4);
t('1e+3', 989.2, 1, 4);
t('1.0e+5', 99576, 2, 4);
t('1e+8', '96236483.87', 1, 4);
// ------------------------------------------------------------------ v8 end
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);
Decimal.rounding = 1;
t('-1.4e+9', '-1336106841', 2, 0);
t('-2244450.2134814273335263', '-2244450.2134814273335262397290334104071203538487453309626146', 23, 0);
t('8.74e+29', '873625255363763952428129881990.679929486040461455296118489', 3, 0);
t('-1.85453549733179613185923288786', '-1.8545354973317961318592328878502252820666161607740183', 30, 0);
t('431.7150651927', '431.71506519265522010949747887049', 13, 0);
t('-8606297211156287.52520023752564', '-8606297211156287.5252002375256362382564355963505470716151', 30, 0);
t('-8.4634889709e+24', '-8463488970828351722405003.220603', 11, 0);
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('-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);
Decimal.rounding = 2;
t('5.80e+18', '5805164734299168659.6173113885173384955443', 3, 1);
t('-1.719875889271327', '-1.719875889271327133154458155573493605566221534', 16, 1);
t('113.672129563', '113.672129563441659725876055771857758675550104070419635029', 12, 1);
t('-77950052814622081084397.9', '-77950052814622081084397.91853869253589242574', 24, 1);
t('4.53106985e+27', '4531069852787151785292512309.2901993579425172826443679877', 9, 1);
t('45285.246089613169416440797840714', '45285.2460896131694164407978407142422013937', 32, 1);
t('307760226411464.7333268079863299', '307760226411464.73332680798632996332324381779707', 31, 1);
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);
Decimal.rounding = 3;
t('-1.7218673528e+29', '-172186735288586033321621121024.11240623', 11, 2);
t('-3.31e+28', '-33197729862068219255677464974', 3, 2);
t('-4.835191326e+29', '-483519132605694848658321267839.23575134378118945659616358', 10, 2);
t('7.3', '7.24882150443803', 2, 2);
t('-89186640077683569.407061427673', '-89186640077683569.4070614276736450982125609', 29, 2);
t('-49379651041268.5', '-49379651041268.548293', 15, 2);
t('-7685054.17489171951660', '-7685054.17489171951660508194254495141726065698575306365447451', 21, 2);
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('-63075151.962465776516325792253177939493172', '-63075151.9624657765163257922531779394931714', 41);
t('7.411461e+17', '741146113404361548.543142388', 7);
t('-58835755359067474972692072494278983.7', '-58835755359067474972692072494278983.6314961114191480012916', 36);
t('-333', '-333', 3);
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);
Decimal.rounding = 4;
t('687378946204028.408158998985701', '687378946204028.408158998985701430935094', 30, 3);
t('42.452', '42.4523909443358871476552683504968536100051', 5, 3);
t('-22771061110217019663705702.44170142085172', '-22771061110217019663705702.44170142085171219649140996', 40, 3);
t('-1470.640309974016167512235698629586', '-1470.6403099740161675122356986295857257144815364', 34, 3);
t('-1.110228e+27', '-1110227398804733429555663947.06619', 7, 3);
t('-6.4898237111e+26', '-648982371105405071851661301', 11, 3);
t('-4641197449469148.658850361201903', '-4641197449469148.658850361201902222', 31, 3);
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);
Decimal.rounding = 5;
t('-8e+26', '-786589693451258754942279859.3834', 1, 4);
t('-26.0', '-26', 3, 4);
t('-8.462226728e+11', '-846222672789.2087639320702375427266333530942524245', 10, 4);
t('-4e-7', '-0.0000004019666978288041783154210868', 1, 4);
t('-315609.775843992', '-315609.775843992', 15, 4);
t('-3.319e+9', '-3318880945', 4, 4);
t('-6', '-6.2847', 1, 4);
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('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);
Decimal.rounding = 6;
t('42334337596496149636254', '42334337596496149636254.4926162509306406461', 23, 5);
t('-7e+9', '-7246374971.34279698356', 1, 5);
t('71516263932998764871838469072', '71516263932998764871838469072.280115355524', 29, 5);
t('71257489.5995227415169007618702182092', '71257489.59952274151690076187021820922744', 36, 5);
t('268492835', '268492834.77041', 9, 5);
t('50325.551277778107847798802', '50325.551277778107847798801525', 26, 5);
t('-5.289303987e+29', '-528930398665449048343281311623.69686', 10, 5);
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('-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('123.45', '12.345e1');
tx(function () {new Decimal(1.23).toPrecision('3')}, "(1.23).toPrecision('3')");
tx(function () {new Decimal(1.23).toPrecision(new Decimal(3))}, "(1.23).toPrecision(new Decimal(3))");
tx(function () {new Decimal(1.23).toPrecision(null)}, "(1.23).toPrecision(null)");
tx(function () {new Decimal(1.23).toPrecision(NaN)}, "(1.23).toPrecision(NaN)");
tx(function () {new Decimal(1.23).toPrecision('NaN')}, "(1.23).toPrecision('NaN')");
tx(function () {new Decimal(1.23).toPrecision([])}, "(1.23).toPrecision([])");
tx(function () {new Decimal(1.23).toPrecision({})}, "(1.23).toPrecision({})");
tx(function () {new Decimal(1.23).toPrecision('')}, "(1.23).toPrecision('')");
tx(function () {new Decimal(1.23).toPrecision(' ')}, "(1.23).toPrecision(' ')");
tx(function () {new Decimal(1.23).toPrecision('hello')}, "(1.23).toPrecision('hello')");
tx(function () {new Decimal(1.23).toPrecision('\t')}, "(1.23).toPrecision('\t')");
tx(function () {new Decimal(1.23).toPrecision(new Date)}, "(1.23).toPrecision(new Date)");
tx(function () {new Decimal(1.23).toPrecision(new RegExp)}, "(1.23).toPrecision(new RegExp)");
tx(function () {new Decimal(1.23).toPrecision(2.01)}, "(1.23).toPrecision(2.01)");
tx(function () {new Decimal(1.23).toPrecision(10.5)}, "(1.23).toPrecision(10.5)");
tx(function () {new Decimal(1.23).toPrecision('1.1e1')}, "(1.23).toPrecision('1.1e1')");
tx(function () {new Decimal(1.23).toPrecision(true)}, "(1.23).toPrecision(true)");
tx(function () {new Decimal(1.23).toPrecision(false)}, "(1.23).toPrecision(false)");
tx(function () {new Decimal(1.23).toPrecision(function (){})}, "(1.23).toPrecision(function (){})");
tx(function () {new Decimal(1.23).toPrecision('-1')}, ".toPrecision('-1')");
tx(function () {new Decimal(1.23).toPrecision(-23)}, ".toPrecision(-23)");
tx(function () {new Decimal(1.23).toPrecision(1e9 + 1)}, ".toPrecision(1e9 + 1)");
tx(function () {new Decimal(1.23).toPrecision(0)}, ".toPrecision(0)");
tx(function () {new Decimal(1.23).toPrecision('-0')}, ".toPrecision('-0')");
tx(function () {new Decimal(1.23).toPrecision(0.9)}, ".toPrecision(0.9)");
tx(function () {new Decimal(1.23).toPrecision('-1e-1')}, ".toPrecision('-1e-1')");
tx(function () {new Decimal(1.23).toPrecision(Infinity)}, ".toPrecision(Infinity)");
tx(function () {new Decimal(1.23).toPrecision('-Infinity')}, ".toPrecision('-Infinity')");
tx(function () {new Decimal(1.23).toPrecision(1, '3')}, "(1.23).toPrecision('3')");
tx(function () {new Decimal(1.23).toPrecision(1, new Decimal(3))}, "(1.23).toPrecision(new Decimal(3))");
tx(function () {new Decimal(1.23).toPrecision(1, null)}, "(1.23).toPrecision(null)");
tx(function () {new Decimal(1.23).toPrecision(1, NaN)}, "(1.23).toPrecision(1, NaN)");
tx(function () {new Decimal(1.23).toPrecision(1, 'NaN')}, "(1.23).toPrecision(1, 'NaN')");
tx(function () {new Decimal(1.23).toPrecision(1, [])}, "(1.23).toPrecision(1, [])");
tx(function () {new Decimal(1.23).toPrecision(1, {})}, "(1.23).toPrecision(1, {})");
tx(function () {new Decimal(1.23).toPrecision(1, '')}, "(1.23).toPrecision(1, '')");
tx(function () {new Decimal(1.23).toPrecision(1, ' ')}, "(1.23).toPrecision(1, ' ')");
tx(function () {new Decimal(1.23).toPrecision(1, 'hello')}, "(1.23).toPrecision(1, 'hello')");
tx(function () {new Decimal(1.23).toPrecision(1, '\t')}, "(1.23).toPrecision(1, '\t')");
tx(function () {new Decimal(1.23).toPrecision(1, new Date)}, "(1.23).toPrecision(1, new Date)");
tx(function () {new Decimal(1.23).toPrecision(1, new RegExp)}, "(1.23).toPrecision(1, new RegExp)");
tx(function () {new Decimal(1.23).toPrecision(1, 2.01)}, "(1.23).toPrecision(1, 2.01)");
tx(function () {new Decimal(1.23).toPrecision(1, 10.5)}, "(1.23).toPrecision(1, 10.5)");
tx(function () {new Decimal(1.23).toPrecision(1, '1.1e1')}, "(1.23).toPrecision(1, '1.1e1')");
tx(function () {new Decimal(1.23).toPrecision(1, true)}, "(1.23).toPrecision(1, true)");
tx(function () {new Decimal(1.23).toPrecision(1, false)}, "(1.23).toPrecision(1, false)");
tx(function () {new Decimal(1.23).toPrecision(1, function (){})}, "(1.23).toPrecision(1, function (){})");
tx(function () {new Decimal(1.23).toPrecision(1, '-1')}, ".toPrecision(1, '-1')");
tx(function () {new Decimal(1.23).toPrecision(1, -23)}, ".toPrecision(1, -23)");
tx(function () {new Decimal(1.23).toPrecision(1, 9)}, ".toPrecision(1, 8)");
tx(function () {new Decimal(1.23).toPrecision(1, '-0')}, ".toPrecision(1, '-0')");
tx(function () {new Decimal(1.23).toPrecision(1, 0.9)}, ".toPrecision(1, 0.9)");
tx(function () {new Decimal(1.23).toPrecision(1, '-1e-1')}, ".toPrecision(1, '-1e-1')");
tx(function () {new Decimal(1.23).toPrecision(1, Infinity)}, ".toPrecision(1, Infinity)");
tx(function () {new Decimal(1.23).toPrecision(1, '-Infinity')}, ".toPrecision(1, '-Infinity')");
T.stop();
})();

556
test/modules/toSD.js Normal file
View File

@ -0,0 +1,556 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toSignificantDigits');
function t(expected, n, sd, rm) {
T.assertEqual(expected, new Decimal(n).toSD(sd, rm).valueOf());
}
function tx(fn, msg) {
T.assertException(fn, msg);
}
Decimal.config({
precision: 20,
rounding: 7,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
T.assert(Decimal.prototype.toSD === Decimal.prototype.toSignificantDigits);
t('0', 0);
t('0.5', 0.5);
t('1', 1);
t('-1', -1);
t('Infinity', Infinity);
t('-Infinity', -Infinity);
t('NaN', NaN);
t('0', '0', 1);
t('-0', '-0', 1);
t('-0', '-0', 1, 0);
t('-0', '-0', 1, 3);
t('-0', '-0', 1, 6);
t('0', '0', 10);
t('-0', '-0', 20);
t('12.345', '12.345');
t('123456789.12345678912', '123456789.12345678912346789');
Decimal.precision = 5;
Decimal.rounding = 0;
t('123460000', '123456789.12345678912346789');
Decimal.rounding = 1;
t('123450000', '123456789.12345678912346789');
Decimal.rounding = 2;
t('123460000', '123456789.12345678912346789');
Decimal.rounding = 3;
t('123450000', '123456789.12345678912346789');
Decimal.rounding = 4;
t('123460000', '123456789.12345678912346789');
Decimal.rounding = 5;
t('123450000', '123455000');
Decimal.rounding = 6;
t('123460000', '123455000');
Decimal.rounding = 7;
t('123460000', '123455000');
Decimal.rounding = 8;
t('123450000', '123455000');
t('4937809340236234102130.947044664011', '4937809340236234102130.947044664011', 35, 0);
t('337528093391.5', '337528093391.493107', 13, 6);
t('7725982105101004219161075340794084739.771523585576612', '7725982105101004219161075340794084739.77152358557661226998117872661100', 52, 3);
t('52215017456426378512883312970.4861221', '52215017456426378512883312970.4861221', 36, 2);
t('4985349771216.54991391', '4985349771216.54991391072733', 21, 4);
t('1101895947.92763', '1101895947.92762954984827601473036438720818296', 15, 4);
t('20026847', '20026846.9372', 8, 6);
t('8204561821674316833270', '8204561821674316833266.047893028353', 21, 2);
t('7419720696218', '7419720696218.21961188299387526', 13, 1);
t('635000000', '634438520.50126453', 3, 0);
t('28392130715407969', '28392130715407968.96', 18, 5);
t('36765276128959576253780217524271972128', '36765276128959576253780217524271972127.99', 38, 2);
t('88429990502356839.49260500060049004694585659', '88429990502356839.49260500060049004694585658780656', 43, 4);
t('2768479', '2768479.2081810557738981722324989595', 7, 1);
t('85601900000000000000000000', '85601959550632180897338814.9', 6, 3);
t('3911951424308151086107907934806060', '3911951424308151086107907934806062.45495666964', 33, 5);
t('892162270787217755968010370478903185093', '892162270787217755968010370478903185093.0', 42, 6);
t('8018330257774248398702693271920270', '8018330257774248398702693271920270.09311146148062547723636185680287073', 33, 1);
t('88092477731945.1182807043', '88092477731945.118280704259340858', 24, 4);
t('9252541030951.9012531009707842372724161089075754576', '9252541030951.90125310097078423727241610890757545760', 53, 3);
t('90993285126.547129568419776', '90993285126.5471295684197756642787492493375', 26, 6);
t('315137924718839945152625512241078.591350724696151650603', '315137924718839945152625512241078.59135072469615165060341097372', 54, 1);
t('822866202506325637.7', '822866202506325637.740891965300', 19, 3);
t('78407276142689114300000000', '78407276142689114391801017.43776', 18, 1);
t('13199803085352251536787921', '13199803085352251536787920.6016623911545535514918245', 26, 2);
t('708.66442', '708.66442', 11, 0);
t('96426394035800000000000000000', '96426394035875521556520436906.967758064780068220269263413347', 12, 1);
t('297.1386227802795046531729004026', '297.1386227802795046531729004026975', 31, 3);
t('98291.739', '98291.739', 9, 2);
t('93', '93.078130', 2, 5);
t('0.001', '0.00099999999999', 3, 0);
t('0.000999', '0.00099999999999', 3, 1);
t('56300000000', '56281970459.86927925182', 3, 6);
t('565000000000', '565914070913.993334452356', 3, 1);
t('3979389667144941000000000', '3979389667144941900427982.77071', 16, 3);
t('52352220229587840556187937111046743.4583563', '52352220229587840556187937111046743.458356312735390953445935426160537204', 42, 4);
t('36271.3981207141751333261', '36271.39812071417513332613', 24, 1);
t('4739543704210300000000000000', '4739543704210297904547136327.7628335972128075226361512', 15, 6);
t('37661669615568080247052723032589226.8', '37661669615568080247052723032589226.77024153', 36, 5);
t('9645371928851642074344527881477634000', '9645371928851642074344527881477634345.4914341', 34, 4);
t('698149777646326000000000000', '698149777646325814282220973.088797026232', 15, 2);
t('18498919087448435591833490000000', '18498919087448435591833489904295.729717528', 26, 5);
t('325969900850571568339999253781743124500', '325969900850571568339999253781743124504.0', 38, 5);
t('40693000000', '40693051631.1251783538001747467807789871', 5, 4);
t('810710395413475993', '810710395413475993.394678', 18, 3);
t('86568781977428682.3822270220321', '86568781977428682.38222702203211', 30, 5);
t('427897046936740724.911837668090826906087', '427897046936740724.911837668090826906087', 41, 3);
t('8248561437515605126456247769501697.764', '8248561437515605126456247769501697.764296656999', 37, 4);
t('5727898467119496952445688320883475.404402704196931184674675825', '5727898467119496952445688320883475.404402704196931184674675825', 64, 4);
t('8752958499919994791000000000000000', '8752958499919994791191031106105979.47729', 19, 5);
t('362154165751.582202112646276', '362154165751.58220211264627597398064', 28, 5);
t('11000000000000000000000000000000', '11914671819298396166152780469749.700178398572262303378530442966993', 2, 1);
t('84694.019523885', '84694.019523885', 16, 1);
t('46198004778598591438177002960.8079419769', '46198004778598591438177002960.807941976894036', 39, 2);
t('944540023268478392955679.235197603187056475911', '944540023268478392955679.235197603187056475911190458898708904', 45, 5);
t('6384.0533', '6384.0532734075270642890', 8, 0);
t('86.52585963444630269524402336034067', '86.5258596344463026952440233603406633365294', 34, 0);
t('211698906765339555009000000000000', '211698906765339555008927202275920.017666588018743809326', 21, 6);
t('93695.521776', '93695.521776317122397800801736652801', 11, 3);
t('21', '20.73571174', 2, 0);
t('44651390355733081311803973.631', '44651390355733081311803973.6306343', 29, 2);
t('19628275338135891273639233000', '19628275338135891273639233078.3194337412', 26, 1);
t('715174732399634482855366624736839961.178974112796', '715174732399634482855366624736839961.1789741127950654699759400963516', 48, 0);
t('4010185.194165679', '4010185.1941656790873904791', 16, 1);
t('199763544.3', '199763544.2746', 10, 5);
t('792604593150000000000000000', '792604593148129965009152274.7', 11, 5);
t('95649091688620000000000', '95649091688615551968376.399825', 13, 6);
t('910000000000000000000000', '913366499416274482076806.54925361292970753237933', 2, 4);
t('5713.74819', '5713.7481900', 13, 6);
t('167100', '167006.16906099738293329453555919087', 4, 2);
t('91.8149489203336825896217615649', '91.814948920333682589621761564879978', 30, 6);
t('385450160421689186188707104582074317519.6', '385450160421689186188707104582074317519.5011', 40, 0);
t('980700000000000000000000000000', '980624231078939283428476194025.3425674466530668543518761186154209', 4, 0);
t('338479692666105014616000000000', '338479692666105014616253331245.01389376828879865108105798429640384', 21, 1);
t('174223066779502216000000000', '174223066779502215997051823.30021471115775', 19, 5);
t('321274436690589321065314360761529600', '321274436690589321065314360761529598.3926958740287183203559360243861156', 35, 0);
t('965260000000000000000000000000000000', '965258557685921663672915807775689926.372616852406174796393011112241', 5, 5);
t('20495856361024494227552150059704.128252538', '20495856361024494227552150059704.12825253784', 41, 0);
t('347539608767858771651414903881.81676443931828298', '347539608767858771651414903881.816764439318282980413', 47, 6);
t('319471356791473500000000000000000', '319471356791473556138054433838044.90552027814', 16, 1);
t('3758410000', '3758411337.659079355464558774017310777636076246', 6, 1);
t('986791401418080896.725674945574053721614668858858', '986791401418080896.725674945574053721614668858858', 51, 4);
t('172860000000000', '172864222463390.0005522631729828976762398559', 5, 5);
t('56.049', '56.049', 6, 6);
t('8343815925404573683080000', '8343815925404573683077429.4758959133829073879054267509464514', 21, 4);
t('5454663865.0064130258909884643960591289', '5454663865.006413025890988464396059128886823', 38, 6);
t('9581036221000167548404063617040830845674.8563402624162914896', '9581036221000167548404063617040830845674.8563402624162914896694713537', 59, 1);
t('500000000000', '410956568424.9910595380985324', 1, 0);
t('32006369380000000000000000000000000', '32006369376256480193142996925472582.0', 10, 0);
t('5222032172895746.90277', '5222032172895746.902766092011', 21, 4);
t('8439793217442.92', '8439793217442.92137711335321', 15, 4);
t('9.866065033617488770826998', '9.8660650336174887708269980', 28, 4);
t('44049352.2266915297896690888554259285496418688', '44049352.22669152978966908885542592854964186877', 45, 0);
t('26847260395161412327091304326000', '26847260395161412327091304326394.7663271691497120655790427', 29, 3);
t('1000000000000', '1085137384726.66574913879922622187703130425247', 2, 3);
t('9.946', '9.9456', 4, 6);
t('428952193056.953', '428952193056.953', 15, 6);
t('1941911780790529313259513.70860258', '1941911780790529313259513.70860257943008396576247829795083', 33, 5);
t('23968438750336.405474280759814', '23968438750336.405474280759813318106', 29, 0);
t('315154230499048000000000000000', '315154230499048332963529384927.93303628365695160150210696280635993802', 15, 5);
t('6500000000', '6480935501.55496974285182162603356273156890', 2, 4);
t('42302765724017563090210326618736869271', '42302765724017563090210326618736869270.98392129213256644255722', 39, 2);
t('608747404736337255085100901273291565', '608747404736337255085100901273291565.318094268584914528314761117', 36, 3);
t('3154176290801000000000000000', '3154176290800715548619630621.0355772810773559541', 13, 4);
t('38865242750002932570887590800000000000', '38865242750002932570887590890877550733.5505553313425194996432914268372269', 27, 1);
t('59457914554626139.52', '59457914554626139.52065942543632055255656', 19, 5);
t('8728384988174071448.69', '8728384988174071448.69274', 21, 4);
t('8209486790494710645762862448749.80842396605900775935', '8209486790494710645762862448749.80842396605900775935', 54, 1);
t('963188883728.74069481457014205', '963188883728.740694814570142059', 29, 3);
t('93249710101545870000000000', '93249710101545874917863173.03705388925', 16, 3);
t('88179259072684818766023076456.5889523232', '88179259072684818766023076456.58895232320350', 39, 4);
t('776981797289252251.093401546863758214465', '776981797289252251.093401546863758214465286704664334', 39, 4);
t('188670879464255056850261739500000000000', '188670879464255056850261739507365918265.9293874736873279', 28, 1);
t('790372524561301386433116300000000000', '790372524561301386433116293301042112.0', 25, 2);
t('117626300000000000', '117626347290152284.584779', 7, 3);
t('353396834933281759072773.805789609148', '353396834933281759072773.805789609148', 37, 4);
t('4274522263032700000', '4274522263032712850.0041729873', 14, 4);
t('8350000000000', '8345606845226.45566624', 3, 6);
t('7139338928.10029575', '7139338928.10029575', 19, 2);
t('1.28993795996', '1.289937959964596899900', 12, 3);
t('581091710823050000000000000', '581091710823047241756858512.713357759428', 14, 0);
t('4952915437691054280969583000000', '4952915437691054280969583218972.8616946954635715417980', 25, 1);
t('9705894787100000000000000000000000', '9705894787058704299917761166078683.9910480951422', 11, 5);
t('3709152457254657158536681.732705728776998763593525103', '3709152457254657158536681.732705728776998763593525103159733', 52, 3);
t('186530566473536251263.858877958', '186530566473536251263.858877958474287539', 30, 4);
t('18185426229191232807040619835808.46825483359797368754', '18185426229191232807040619835808.46825483359797368754', 52, 3);
t('41.5133038761731262218686', '41.51330387617312622186860688055631484', 24, 4);
t('892734300000000000000000000000000000000', '892734285316609348922285835347841194677.279150490649933902110687168010', 7, 4);
t('8867741117000000000000000000', '8867741117136144692773028671.48789537068725372709865944763', 10, 4);
t('58066.6119296613521', '58066.611929661352058113440', 18, 0);
t('610095820904.3119523193', '610095820904.311952319394878656597629841829693065', 22, 3);
t('45147764430505826.0397992803707428783769210234', '45147764430505826.03979928037074287837692102337', 45, 2);
t('2365934669507425116.685560049269016191', '2365934669507425116.685560049269016191181112056065', 37, 4);
t('76328567052192004276.32866340568679575775108106109', '76328567052192004276.3286634056867957577510810610864', 49, 5);
t('9341865065715748.71038922653450359770952', '9341865065715748.7103892265345035977095284', 39, 3);
t('1893828187345809.95025475161610431769040580234726', '1893828187345809.95025475161610431769040580234726', 51, 5);
t('675418012725769678669671724576651465', '675418012725769678669671724576651465.457619554107058395110952042747864102', 36, 5);
t('722723049408340056285000637093.2', '722723049408340056285000637093.1564846486282233386998', 31, 2);
t('8039307818523262169309113965.237955673046573', '8039307818523262169309113965.2379556730465735379', 43, 1);
t('620699795.768772003', '620699795.7687720027642576108299448', 18, 6);
t('677976409911497700000000000000000', '677976409911497719121490267737187.9281869113', 16, 1);
t('9913200270263800000000000000000000000', '9913200270263779985846761891158202865.88', 14, 2);
t('95447550983654000', '95447550983654256.94', 14, 5);
t('9727301256933984906097986874000', '9727301256933984906097986873657.0', 28, 0);
t('83100000000000000000000000000000000', '83144797009396341772640576982431626.06487716198510170943250663066', 3, 5);
t('76723773.04423217932', '76723773.0442321793176553237', 19, 6);
t('8400000000000000', '8442290748483192.541766601132013892502484734171240', 2, 5);
t('80224755820119141339232053676610000', '80224755820119141339232053676618497.04561623225397344999', 31, 3);
t('655778655223372.97', '655778655223372.965', 17, 0);
t('20184630477822715391390984001199.1866444533896426202887666335307182015', '20184630477822715391390984001199.1866444533896426202887666335307182015', 71, 6);
t('41930826996134220', '41930826996134221.1974945198118251722677898312235505', 16, 6);
t('9401169208627113200000', '9401169208627113178099.432092017583166044', 17, 6);
t('46844285000000', '46844285165612.4277871838', 8, 5);
t('732653734623947749013990.255', '732653734623947749013990.2554245257179', 27, 3);
t('817615530000000000000', '817615525922580553380.874869911815006035161427956123678666', 8, 5);
t('648900000000000000', '648881720909905928.428439970149048878644930752628', 4, 2);
t('85228991367.461452', '85228991367.46145277847248857183769451804173', 17, 1);
t('239393776.69622644151182', '239393776.69622644151181623925655', 23, 4);
t('33546748243104239469877559937.363355786582993', '33546748243104239469877559937.363355786582993', 44, 0);
t('4000000000000000000000', '3823084385271016278125.11', 1, 5);
t('77046259820455751626.6026808001342537', '77046259820455751626.602680800134253741613198881', 36, 6);
t('26687373854107297015683.744', '26687373854107297015683.74432725585956728677271691574', 26, 3);
t('976672549609984585227222778700000000000', '976672549609984585227222778792212901570.55874088', 28, 1);
t('2.5616142669200936365611', '2.561614266920093636561053', 23, 2);
t('94492716203969.2225869573684291964191137943094515', '94492716203969.2225869573684291964191137943094514534843', 48, 0);
t('990770621178724769771370000', '990770621178724769771371129.99176486560800414', 23, 3);
t('691412410360950760000000', '691412410360950750128020.48447221650237091009047', 17, 0);
t('29040659564825201725590.2424704967395', '29040659564825201725590.2424704967395', 38, 2);
t('89559092584017288521728982.5', '89559092584017288521728982.5833198608864', 27, 1);
t('1811614362251924.40512130616', '1811614362251924.405121306157849629', 27, 6);
t('4633501475000', '4633501474602.054640995909183', 10, 0);
t('678705341261.75297583718425453684090101', '678705341261.7529758371842545368409010097945103677', 39, 6);
t('564078844253167778.8161248928271829563591373580664298', '564078844253167778.8161248928271829563591373580664298', 52, 0);
t('88322850583909.7416016241', '88322850583909.74160162410286643', 25, 1);
t('3846366946174062127758449605.7022758096', '3846366946174062127758449605.702275809555523634154040950898280612811', 38, 6);
t('89658733400000000000000000000', '89658733356696254546423515335.28349', 9, 2);
t('4761467.862', '4761467.861150141326149685649922793395', 10, 2);
t('179.92617', '179.9261669', 8, 4);
t('75069004857851352687270011001106689339.08735', '75069004857851352687270011001106689339.08735', 46, 5);
t('3361644609630676688091028947986494293.045392455143082675351', '3361644609630676688091028947986494293.04539245514308267535094798418063548394', 58, 2);
t('6.7942421735585618046', '6.794242173558561804595', 20, 4);
t('51657502980255968504333490637.09662892780318174480380404', '51657502980255968504333490637.0966289278031817448038040396600018487', 55, 5);
t('11855.226308528', '11855.226308528', 16, 6);
t('61277000000000', '61276347667662.405824737', 5, 0);
t('4174609640', '4174609636.0', 9, 6);
t('687936219719625022378.9502', '687936219719625022378.9502057605855', 25, 3);
t('193757131563910000', '193757131563911904.52682306122527060962641882465', 14, 6);
t('387.455087', '387.45508661743', 9, 6);
t('557618201766183005000000000', '557618201766183005041293682.3722668213410766424816487716234273', 19, 6);
t('21128122508600497.05489', '21128122508600497.05488760', 22, 6);
t('630252144005109.53366072283861382', '630252144005109.53366072283861381792', 32, 4);
t('963826907622.364662995276', '963826907622.364662995275692188', 24, 2);
t('4212653046051913081783119467271.37647511439591502128556', '4212653046051913081783119467271.3764751143959150212855631', 54, 3);
t('2014467765.30542656127', '2014467765.30542656127', 22, 4);
t('1479320000000000000000000000000000', '1479326666751842221164864465643932.73817033951340680', 6, 1);
t('6944862581642049969018412438205282752.728862', '6944862581642049969018412438205282752.72886131507563067413320187385623099', 43, 2);
t('9838375.64', '9838375.645', 9, 1);
t('73392897409456861290131541129654.9256075066904', '73392897409456861290131541129654.925607506690362687103367844755771', 45, 4);
t('89764270000000000000000000000000000000', '89764275311096607184088076035578686331.70483764463153360153147271493', 7, 1);
t('615391331037547517357702.9541121335087', '615391331037547517357702.9541121335086812', 37, 5);
t('2617216902482291199973663.484710966125', '2617216902482291199973663.484710966125', 37, 4);
t('17129271618518517092155339580000', '17129271618518517092155339589985.34795326188', 28, 3);
t('606535160521504794000000000000000000000', '606535160521504794060646691380816193844.7', 18, 5);
t('34177380606532061226000', '34177380606532061225426.5490340', 20, 2);
t('537578.927123', '537578.9271229227', 12, 0);
t('5008643590729908333990610000', '5008643590729908333990609905.47558686510363696', 25, 5);
t('4895936188848030000000000000000000000', '4895936188848031794116383643496168477.0801543', 15, 1);
t('5683079691081606113599129167429526013511.48652875855', '5683079691081606113599129167429526013511.486528758557663781739723321875379906235', 51, 3);
t('8629922951113.7511448487597458660248521234', '8629922951113.7511448487597458660248521234380600977', 41, 4);
t('90278102650946226014809000000000000', '90278102650946226014809046003862793.7835979911', 24, 3);
t('4821625627675322025353636064.57176', '4821625627675322025353636064.57175523338580806993894351876', 33, 4);
t('201458719700489100373654957.825506491000336059519682', '201458719700489100373654957.8255064910003360595196823588160', 51, 3);
t('53212790802213594493332', '53212790802213594493332.8650736614584969129110', 23, 3);
t('8177197143472082210310164500000000', '8177197143472082210310164503390974.89434', 26, 3);
t('6977664457930000', '6977664457920874.47627073206781', 12, 2);
t('48200644415566530.498484', '48200644415566530.4984835390397628883909840', 23, 0);
t('4000000000000000000000000000000000', '4192746732983495210446560254097740.47028995', 1, 1);
t('755.023209', '755.02320914910644', 9, 6);
t('66963000000000000000000000000', '66963023876901420169077780295.01885877196', 6, 3);
t('505291668854707.70906269', '505291668854707.709062685721555135520850266111469308027', 23, 4);
t('664850.618013', '664850.61801224118433274591608772154387', 12, 0);
t('785103038952630143044641569204316756.63797054791874616052822183467149', '785103038952630143044641569204316756.637970547918746160528221834671492', 68, 6);
t('4146164592920910235341149.587', '4146164592920910235341149.58704019746296185479', 29, 3);
t('579742066579367045736.917004843230287530285579', '579742066579367045736.9170048432302875302855793', 45, 4);
t('92817.84445', '92817.84445', 13, 4);
t('772179455775.22422834897', '772179455775.22422834897889', 23, 1);
t('4670558124138300', '4670558124138345.3777942422216231', 14, 3);
t('11653701002.1779016933207', '11653701002.177901693320687576204027037389422679', 24, 6);
t('661971346000462043332006500000000000', '661971346000462043332006546474696174.7167702709539', 25, 4);
t('7951.2507068', '7951.2507067915133', 12, 0);
t('83825.91569730694896932060436944', '83825.915697306948969320604369447056', 31, 1);
t('179989.23863077943963', '179989.23863077943963', 21, 2);
t('333610464960022048972485697598948476.3274927278', '333610464960022048972485697598948476.32749272770013219331', 46, 2);
t('567620976076010000000000000000', '567620976076010425435148100001.0364396667132672575976', 14, 5);
t('25166561739090000000000000000', '25166561739091850523119786031.356417774102', 13, 1);
t('35769804358466980414449956124427509', '35769804358466980414449956124427509.31366843647801642057', 35, 5);
t('5624000000000000000000000000000000', '5623994624926506484134510384338582.7213130433076592758171270720102084', 4, 2);
t('52471579263868610000000000000000', '52471579263868615271801405152771.014318284628313', 16, 3);
t('800000000000', '754585116996.9768', 1, 0);
t('6845902810000000000000000000000000000000', '6845902808062306446526711601148487105964.760230279341124548333865130108451155441', 9, 2);
t('25329930000000000000000000000000', '25329931835642796295008712007359.774', 7, 6);
t('838205133360935.04', '838205133360935.0450208', 17, 1);
t('960000', '964483.4958501605537391', 2, 4);
t('6985940160812637750037427078390489093.5972419', '6985940160812637750037427078390489093.59724194766104006296648646911097283', 44, 4);
t('85912832521353633900000', '85912832521353633962171.622844738617471351787937', 18, 1);
t('22537.04', '22537.044131504334747686356', 7, 4);
t('64820082671929139423989159247959991.27439244549390817', '64820082671929139423989159247959991.2743924454939081683', 52, 2);
t('81309794072838871318854500310152.093', '81309794072838871318854500310152.09295684998521', 35, 4);
t('2983.146', '2983.146', 8, 0);
t('7649851971073922220000000000', '7649851971073922227632383137.12367829277753284010508541882606785617', 18, 1);
t('4413319948694474085791.6528747', '4413319948694474085791.65287472187114939173359969', 29, 1);
t('9169434008670526360155.858673', '9169434008670526360155.858673447171266307242005', 28, 4);
t('87281481541792866.31680021820096', '87281481541792866.31680021820096251746992578412', 31, 3);
t('1262882505899773546530000000000000000', '1262882505899773546530078940105109255.1340263465677131821878853130', 21, 1);
t('90957735119480552000.1275792566121', '90957735119480552000.12757925661213812317307', 33, 3);
t('95094204140327.386800069607', '95094204140327.3868000696069952245821304362528', 26, 6);
t('782.8315804028037', '782.8315804028036627332091761646906', 16, 4);
t('4070074897815719013854405000000', '4070074897815719013854404930086.0517196', 25, 2);
t('7535527006575666259327800', '7535527006575666259327801.3118771661605538067531702602254', 24, 5);
t('993000000000000', '992026987647463.516668', 3, 0);
t('4698757980923794411324653119136506649753.9058533965214', '4698757980923794411324653119136506649753.90585339652148316962906302356153227', 53, 1);
t('338765415.622999075063635041304250288156393', '338765415.62299907506363504130425028815639273842', 42, 6);
t('444000', '443272.8', 3, 0);
t('92863547832.26', '92863547832.25594', 13, 0);
t('227484121340486.542512', '227484121340486.54251108296', 21, 0);
t('7034', '7034.0', 7, 2);
t('84677601800000000', '84677601708231089.8035199547', 9, 2);
t('903992663388421800000000000', '903992663388421818078667246.7494838726767325648', 16, 3);
t('9440650000000000000000000000000000', '9440656634642185509393801198086015.4', 6, 1);
t('916417601649800000000000000', '916417601649865583796921805.163932264102471440203390988', 13, 1);
t('3546786323316815500000', '3546786323316815404869.163629407284618604', 17, 2);
t('747408692550834866360911935.8990445275165282197802717382548', '747408692550834866360911935.89904452751652821978027173825483', 58, 3);
t('29804424518.256135774', '29804424518.256135774', 23, 2);
t('15732791881955773293163440652450', '15732791881955773293163440652451.44291076191144', 31, 1);
t('82293484047103499038.6975422642147137771867866208', '82293484047103499038.697542264214713777186786620705401', 48, 0);
t('5288356.17', '5288356.17', 11, 2);
t('75977708959803656203251104.81675609237952293524970939', '75977708959803656203251104.81675609237952293524970938678', 52, 4);
t('1958555193503000000000000000000', '1958555193502587409635649733733.584', 13, 2);
t('61097901998.6487577', '61097901998.6487577', 21, 3);
t('4966635612645365.09586650722463', '4966635612645365.095866507224630866586307217888782761159', 30, 6);
t('449349314276161751863885318023458.255606199257691366208268573', '449349314276161751863885318023458.255606199257691366208268573', 61, 6);
t('3313802055037244406355.1441269459053985', '3313802055037244406355.14412694590539847622267', 38, 5);
t('77476038634229841225203.057294319605', '77476038634229841225203.05729431960467859218', 35, 6);
t('532731523000', '532731523075.4101466861580822959', 10, 1);
t('279000000000000000000000000', '279332110982355758954949172.19150963', 3, 5);
t('76199428363070721667903.826669566', '76199428363070721667903.826669566165506057243720918746', 32, 6);
t('297600', '297631.47066887', 4, 3);
t('8248110729241783273113.562111307100337407', '8248110729241783273113.562111307100337407', 40, 2);
t('1000000000000000000000', '1236453638891742153022.8348728811', 1, 4);
t('535330000', '535327351.8008', 5, 2);
t('4308.58715419601937041522', '4308.58715419601937041522', 24, 5);
t('13500654611668894713386183570622548.34241', '13500654611668894713386183570622548.34240861579', 40, 5);
t('995.7155821993173011608323', '995.71558219931730116083231270171862650', 25, 3);
t('239147599253876718.9504433491173273', '239147599253876718.95044334911732723218139304606724752', 34, 2);
t('765497722616.8961003646', '765497722616.896100364573390975890478644136740197458', 22, 6);
t('101979298537.68788178219', '101979298537.6878817821900758850756870223612522530', 23, 3);
t('54564000000000000000000000000000000000', '54563203006377285590954695127259934956.72304700', 5, 2);
t('937851991874226678.2', '937851991874226678.191965007088457', 19, 0);
t('9141378468539383564638997660000', '9141378468539383564638997666387.513564869223', 27, 1);
t('5140000000000000000000000', '5143738381911696659148152.2424402227698278853166', 3, 3);
t('20497199023806.45608949', '20497199023806.45608949227987004920339939', 22, 5);
t('81603182.7', '81603182.616632542195753770061305729184', 9, 2);
t('1288222268118280000000000000000000000000', '1288222268118271079758562419926059399472.4003871704903395624929468673346838726', 15, 2);
t('484726059819530000000000000000000000', '484726059819531746596562275263672330.122283607', 14, 3);
t('680000000000', '675623616750.993125132354', 2, 4);
t('87687220439051000000000000000000000000', '87687220439051554697153502010194056104.42861', 14, 1);
t('2844992735024778164396876428400000', '2844992735024778164396876428386392.397101880541673725', 29, 6);
t('4910468313236974384325553954.559', '4910468313236974384325553954.558968559307060603568610', 32, 4);
t('7677382468596942606325100814949164462.335409794', '7677382468596942606325100814949164462.335409794', 49, 1);
t('6958724457786172481654532020985.043', '6958724457786172481654532020985.043', 34, 2);
t('460800', '460705.8028929240198868371532360965971117977776', 4, 2);
t('81763325373301098575053681.009551104718485', '81763325373301098575053681.0095511047184850495148390898', 41, 5);
t('77290000000000000000000000000', '77298476544997406115741457621.48100777755241170668034650809', 4, 1);
t('2862358127844547877974880690522730000', '2862358127844547877974880690522726982.49409754', 33, 2);
t('901843956540041489372610610000', '901843956540041489372610614345.487929674', 26, 5);
t('45031671217607058672836306.48351134', '45031671217607058672836306.4835113355599', 34, 4);
t('92083948494159391284091144794664446.380059732506918919702', '92083948494159391284091144794664446.380059732506918919702007475113945', 58, 3);
t('177322371367658020851649000000', '177322371367658020851649147602.975655295218030854293908400956', 24, 3);
t('4239542600712473433498612753.21060144321763992555366', '4239542600712473433498612753.2106014432176399255536577373285045425339', 51, 4);
t('989142489.56454046202042259', '989142489.56454046202042259', 29, 6);
t('39188324760962.64171', '39188324760962.641710', 19, 0);
t('1784374158800', '1784374158866.4741261545314002975498', 11, 1);
t('4889335896817404.6714320041572203', '4889335896817404.6714320041572203348794', 32, 3);
t('3179414685590000000000000000000000', '3179414685592371949442250485606819.26696750990296429734141944', 12, 6);
t('2903.26350044', '2903.263500440', 13, 3);
t('1491343.789445631775761446419118151', '1491343.7894456317757614464191181515356911640598', 34, 3);
t('5500628286601049.843663626181949', '5500628286601049.8436636261819485793447808823573910', 31, 4);
t('3974711265332457200000000000000', '3974711265332457176491911497563.9361', 17, 4);
t('93.28105427667321036', '93.281054276673210359', 19, 2);
t('79910228655846918061600000', '79910228655846918061589185.101353368484158631096929283677512827019', 21, 0);
t('4389523222041915395738636382677027050000', '4389523222041915395738636382677027049670.297472800121808897652436', 36, 0);
t('2894245566479613750113978122489420.5686284128195803188', '2894245566479613750113978122489420.56862841281958031877868147223357225', 53, 4);
t('494724446222447272134436118293973049042208245586819785140130787553487687286873291327585520984443687211379965781311260864429223913901690400000000000', '494724446222447272134436118293973049042208245586819785140130787553487687286873291327585520984443687211379965781311260864429223913901690493449434874.049', 136, 1);
t('3720280055397389210963282787773692958098570405431190000', '3720280055397389210963282787773692958098570405431182098.1847115996658646089352534779938945383741184042776917885782743812931817237846474528789801', 51, 0);
t('759188909745876678229347606524330959678969850255912440680257260789800000000000000000000000000000000000000000000', '759188909745876678229347606524330959678969850255912440680257260789793508531411911105662225225721357883400623102.881476662045026352517268398904498921045685377855106763679514746737986172605517588709155551610890784878010336772838372711497238975980355571170655725075915881399899070771273619112223837705596667049149981193', 67, 0);
t('4534304542844843415257043214798844424046834211704366877715023555011150000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', '4534304542844843415257043214798844424046834211704366877715023555011146990876705027962738522155031711274213446497330677820779740785545273317321438460934917531081249158109061429290323393161606391411793.277725444395', 69, 5);
t('527244430907269587850000000000', '527244430907269587847819161754.09994360681344184942353237241149292559482211118493881252182204930127002210488011149670127752911923929048735411637853031498542495512941893603181502188788354208091361643795263910287', 20, 5);
t('500274199038784701912854356303000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', '500274199038784701912854356303168604036329678593776947367198603066622399541094534586945152898619439257327038632128821666524202122658068057432922418958129519085677022999535035083.95723140131476417422632523022711778228314707489949388264508533995136005795122359991', 30, 5);
t('5333760730338237.358128061070265324699616103754480796605292719724271045', '5333760730338237.35812806107026532469961610375448079660529271972427104505398437046671245161686878493124070786536064182194621929641261600482019485630475569955198761522647338125822382150219203146448476750498789080703982026782691017063636782481300', 70, 5);
t('9387762026.7326734940421184446066226146106694714282947260976784456146415402', '9387762026.73267349404211844460662261461066947142829472609767844561464154020', 75, 4);
t('67323858.24741072854262989306161704601101', '67323858.2474107285426298930616170460110072782018778697292704532242132189290371593478382802207909998627911041939764517795222755210476244995305187831767572511625381158475111177037691940475964756887806055996078204829400918467078858084732712280713071351617031612115767601030103857883944259837811618215851568286334400246721991754374286168046011298802236522', 40, 2);
t('618280971398998509245590744944289036083345801467550000000000000000000000000000000000000000000000000000000000000000000000000000000', '618280971398998509245590744944289036083345801467546352624671931393813580337957902732550378613100649571499058004021009366633559571.2699009128705660239887951528338903748244427453200035937983818076678373616991455573', 50, 5);
t('3625212716653626154269212443601969756896707.1563164088370829935116368726319072553580520490616568', '3625212716653626154269212443601969756896707.15631640883708299351163687263190725535805204906165678662625271', 95, 2);
t('279794024756694785000215326702581040764281424692.94416985247012017560069970214089414772133468917746186164351199574782564560451796356697926186392269112385101341672332415427389576261072927099738586782426824776935594024948', '279794024756694785000215326702581040764281424692.94416985247012017560069970214089414772133468917746186164351199574782564560451796356697926186392269112385101341672332415427389576261072927099738586782426824776935594024947823170180686', 218, 6);
t('35828450460504270469704936980280835584645741698641855543514563095433541570683138929790029105719699910360000000000000000000000000000000000000000000000', '35828450460504270469704936980280835584645741698641855543514563095433541570683138929790029105719699910361577052023426681751310480362480069300311248293.15348414532497112250157766681332507724698060759080257429160605105296732683871024', 103, 6);
t('43761815435821313568192740041070231887308670966477475362204961804611459661458966510873830168.716748692490194916680548288518654884099098683415405589451450981728769866802762326739', '43761815435821313568192740041070231887308670966477475362204961804611459661458966510873830168.716748692490194916680548288518654884099098683415405589451450981728769866802762326738670533948709724357936162347635031179866244', 176, 2);
t('9940289055903627512125768245502992585069900170400000000000000000', '9940289055903627512125768245502992585069900170399503819515972524.13568735283721983801757702683853241247769318405229726113276035561474837566466532875876277432576610830142188269641845050335097656359864498101396326004092685742327518181101473104745549408201476216574093693733574369506676184899821529267868141813088352688031339966846243166921375083445250920', 47, 4);
t('47308500490651000672647597245353550222048575.807214284239202', '47308500490651000672647597245353550222048575.8072142842392016063606507543350997595316613513575837073421103918284314912676250088610064455343463233565051257974791197641171878251624763412467738389496245200149213715671349161', 59, 4);
t('7242493899945961184657078755114354.8275694408198985015345976108000512015550224515265362601958484547530262', '7242493899945961184657078755114354.827569440819898501534597610800051201555022451526536260195848454753026282935514547388140', 104, 1);
t('4984463523458535754905264911455285850008993268231053980.767410232956686367696506915282296297', '4984463523458535754905264911455285850008993268231053980.767410232956686367696506915282296296709367816894555456665962274719887159413483764425930136761749360042065357118267648394706165913383308575864809558314678492797545419', 91, 0);
t('468731093093191466545712621915352193328466285392879958862956252122614534959310655639000000000000000000000000000', '468731093093191466545712621915352193328466285392879958862956252122614534959310655638837578478177944653136138911.41840552882713558913968005741142943', 84, 5);
t('8722796170843759397737441130128801601794238071659409548210220188790585826046201831648630668253198051544084586185006178347748234700', '8722796170843759397737441130128801601794238071659409548210220188790585826046201831648630668253198051544084586185006178347748234759.9434511722086056368943', 128, 3);
t('67926499505419960439966855715456849140496804252323842323150939357112.592612688760262', '67926499505419960439966855715456849140496804252323842323150939357112.5926126887602628389494013461282357363300181486827630507100652279617012866942377850016203733098433364051', 83, 3);
t('1402457858069260843701831542961702005330000000000000000000000000000000000000000000', '1402457858069260843701831542961702005338943536372264316099532808299709640182133143.009979906034715196177295226439746913418590464152810027317068521003207924233662128607269663291833', 39, 1);
t('1106350604097326705139313335803761878947015866282894852274609129769275668488439922176607333011405146481732245401758539986540.94882628447605933696571359709430425378075223612860671428379', '1106350604097326705139313335803761878947015866282894852274609129769275668488439922176607333011405146481732245401758539986540.94882628447605933696571359709430425378075223612860671428378614749989787085552416655512628791179233', 183, 2);
t('9735483775685609464322320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', '9735483775685609464322320520902637418698700323093604913106065125437383414521799911105265912341567164193794949895999422938985317071738708834029942382911270457249378913787.1103832980594904520955978916205703025866141635300875243', 24, 1);
t('489529.68306403435338777825958322163255657451479551721256707088073420494749504360454448131356633', '489529.683064034353387778259583221632556574514795517212567070880734204947495043604544481313566331313388535912869238239769635054162766247017293340447968973686886334804349955536713950306242814646600928789897172058572510482913298938731094634890755913526004290737129748224090241001770940', 95, 1);
t('5916066038388477.282777699215057097344308799257479415453402583912978373402137006855767835024785902898403750237821320238828483034980698804153055853499', '5916066038388477.282777699215057097344308799257479415453402583912978373402137006855767835024785902898403750237821320238828483034980698804153055853498816858707539873771777970182477242160360615721826161461903035810812584828', 148, 5);
t('1492565201039912150941642914851.0188694977647271424918935209921129749064571021507470715331012037266466375367808113130910695243443128008252945554605720303655', '1492565201039912150941642914851.01886949776472714249189352099211297490645710215074707153310120372664663753678081131309106952434431280082529455546057203036546314199747521356134765285561227686693949347029078827406886675694947', 155, 6);
t('9640.823515736412358055650895513069103270437767616274081289588691585664302621579615021666966091360826575410661596403164479300452152684973160363097309608067', '9640.823515736412358055650895513069103270437767616274081289588691585664302621579615021666966091360826575410661596403164479300452152684973160363097309608066484458989787971253015176864265186897585966764740584557961889884222991340777882611717168551975010970695517417044829720982931484654856360759782530622', 154, 0);
t('2192917244999869343205916374337677.13670389941440829125766924482174747890075138055235242239241690214', '2192917244999869343205916374337677.13670389941440829125766924482174747890075138055235242239241690213762402416630046739017177822', 99, 6);
t('63537288045407814614632100373927391371818274269554962.476', '63537288045407814614632100373927391371818274269554962.47539574376947926528280013008702010901972495291817972524796755262276716657735757278', 56, 2);
t('2811000000000000000000', '2810271650889132939296.56710151819671988902086681773799853021233325407901168571657754153770180269049570864269302522698770485556146', 4, 0);
t('315495111097618519547112164879699292983604105741729996616794447864850000000', '315495111097618519547112164879699292983604105741729996616794447864849595569.4732429578938004170666887599581675624557787373713415172397346993864722937610311872942069612761272487587892003117667431497194318776589121114621644677670506783812384346194108237410689252765415071112547238246125156991556184611980318715999133743922164645414546327450499594633872455804056396617969187240487543621620', 69, 6);
t('204.054713812637763806802452', '204.054713812637763806802452', 28, 1);
t('283401218864063400000000000000000000000000000000000000000000000', '283401218864063396558389343623404646465639303535411612743365055.0226824948376888', 17, 6);
t('92229.61758321528485812953091790666786058628679345291222636317052305267319561885415781143567404759366953', '92229.6175832152848581295309179066678605862867934529122263631705230526731956188541578114356740475936695278089617909281727991815396972738914904573285717078598330120780900701772340175710598595012522421761264348230172003217', 103, 5);
t('272730132423593904649945011230989.07441427998296751796431596590750797141803801848817960594928685477662435073578350760298700878428378237445274', '272730132423593904649945011230989.0744142799829675179643159659075079714180380184881796059492868547766243507357835076029870087842837823744527376015781771828747087898039912031366854731319283802355925346531872038489621488183273173863', 140, 2);
t('834882716459088686085166110241864368.2585566209634844197272577905771502073368091374111995246662548601100626717411222217154101996014', '834882716459088686085166110241864368.258556620963484419727257790577150207336809137411199524666254860110062671741122221715410199601367804869545194', 130, 2);
t('17069318170447559670824010313506648026528166586129880725091542343600550422997254786851016215940786230013064180480826097444101000000000000000000000000000000', '17069318170447559670824010313506648026528166586129880725091542343600550422997254786851016215940786230013064180480826097444101017117212949291335428804169206.4789414896747948034966909141270082719485508246318636726728954481', 125, 4);
t('459159626088903852606631649784227594935229835299060973799218279323000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', '459159626088903852606631649784227594935229835299060973799218279323713336570937633103595944583645177507124617629953771475688119656568329467957028808451626080.2157052326772496024245144704394972923671967963191881122863487049025806804492486980444650765391761189341478929086845849828893436948962388818123422', 66, 1);
t('8964893258158025627760261546686868902639753180000000000000000000000000000000000000000000000000000000000000000000000000000000000000', '8964893258158025627760261546686868902639753182992598513279568321959004014846384717934802529654264364024872333833301734962238301019.830652683', 45, 5);
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('-1.11070563555955986e+949884', '-1.1107056355595598537391E+949884', 18, 0);
t('6.31095e+4614231246519714', '6.310954382701729758393260889166675474531891695090516238E+4614231246519714', 6, 4);
t('6.46090322e+6677217159189', '6.460903219125211021E+6677217159189', 9, 6);
t('-3.95798433263891068927612875275729538e+483397', '-3.95798433263891068927612875275729538E+483397', 36, 3);
t('-5.15e+51785', '-5.1495592729221424586275386661E+51785', 3, 0);
t('-8.341297854e+7759443961', '-8.34129785438621486E+7759443961', 10, 2);
t('-7.039038e+648540530527', '-7.03903881158613994150693699720210776203561398962036350248E+648540530527', 7, 1);
t('8.86067409668395196e+553520229219693', '8.860674096683951963219272593791310E+553520229219693', 18, 1);
t('9.864987930516936534e-490626048', '9.8649879305169365348113E-490626048', 19, 1);
t('5.8917903635419393e+46492775', '5.8917903635419392365831E+46492775', 17, 2);
t('3.471651888e-7', '3.4716518879894538148508E-7', 10, 6);
t('3e+350468916', '3E+350468916', 1, 5);
t('2.6e+187364576122710', '2.6468730222404974166287111790752920305E+187364576122710', 2, 4);
t('-8.08170387551427578983625022e-7525724769', '-8.0817038755142757898362502198224521935080928E-7525724769', 27, 3);
t('-5.820926e+137772541213403', '-5.820926E+137772541213403', 7, 1);
t('5.82502531276069650637998468163265673623114802117e+8930012634273', '5.82502531276069650637998468163265673623114802117E+8930012634273', 49, 0);
t('4.844065381013725986837e+6248', '4.84406538101372598683728877E+6248', 22, 4);
t('-6.724e+7494242238106', '-6.7242657973487816694742594494155083518497133669292619495E+7494242238106', 4, 1);
t('-9.4498161648797e+8817051', '-9.44981616487963708105775536177061040387686718038130154486986E+8817051', 14, 3);
t('-7e+7786945', '-7.7313723453361061E+7786945', 1, 1);
t('6.891752e+46766112525827', '6.8917529279486620283885E+46766112525827', 7, 3);
t('-4e-93725726753990', '-4.145441268822437756131965510163E-93725726753990', 1, 2);
t('-1.12e+306023331171748', '-1.118165921482066102466296293946894050652555175E+306023331171748', 3, 4);
t('-7.97933637481027805811243e+5501', '-7.97933637481027805811243624604489711E+5501', 24, 2);
t('7.21004626e+398740640897153', '7.2100462602152007419973593468751658532E+398740640897153', 9, 4);
t('-7.936e-43130', '-7.93600951E-43130', 4, 4);
t('-1.80564432714468488631383756914281144946839362e+1359', '-1.80564432714468488631383756914281144946839361818525E+1359', 45, 6);
t('-4.628554324020425e+5815991268494', '-4.6285543240204252524099493990932424634348E+5815991268494', 16, 5);
t('-3e+15499', '-3.0E+15499', 5, 1);
t('1.77529e+5442970395990', '1.77529E+5442970395990', 6, 2);
t('-3.393352377819527802023568109492373e+725647954123', '-3.393352377819527802023568109492373656E+725647954123', 34, 1);
t('-9.51113913923830633451150121829e-868', '-9.5111391392383063345115012182879189612993491E-868', 30, 5);
t('-7.92283e+78175', '-7.92283E+78175', 7, 5);
t('4.841677133170436816434246233e+30639158262', '4.8416771331704368164342462331056980108405981E+30639158262', 28, 1);
t('4.5e+9325666044026', '4.45420164905655927661142848292149E+9325666044026', 2, 4);
t('1.3e+971860873519992', '1.3393718841216445941247869301225022E+971860873519992', 2, 4);
t('9.876242886531e+52605', '9.876242886531446435944603618104763457E+52605', 13, 1);
t('6.330647937407025476697e+1768', '6.330647937407025476696971741E+1768', 22, 2);
t('5.2068922505677208e-3336', '5.20689225056772082748E-3336', 17, 5);
t('5.92809e+23046663', '5.928089832984E+23046663', 7, 5);
t('-8.5013637538e+888365717321295', '-8.50136375387653962573285296809772512970778623629235925E+888365717321295', 11, 1);
t('4.26475618712602071344874281e-62604', '4.26475618712602071344874281748487391782E-62604', 27, 3);
t('9.020713898414363807382134e-1', '0.9020713898414363807382133864186995', 25, 6);
t('7.09e+2242265227092', '7.0838E+2242265227092', 3, 0);
t('-2.6239193037e-459', '-2.6239193037415483309716069E-459', 11, 2);
t('2.08714059942275969e+28', '20871405994227596829475710887.232303900189115941377511040', 18, 2);
t('-3.21984e+66642478', '-3.219846203541755078720574281120717190883E+66642478', 6, 2);
t('8.08261507044993075472382557081796361683467812687673683e-4976', '8.08261507044993075472382557081796361683467812687673683E-4976', 57, 0);
t('5.5100964862850252990176e+0', '5.51009648628502529901761683407913552', 23, 4);
t('1.71255625197e+623', '1.712556251979341826880397489279E+623', 12, 3);
t('3.481615e+9752693', '3.4816153525988774411598020196959004888E+9752693', 7, 3);
t('3.509821e+91098992', '3.5098208203E+91098992', 7, 5);
t('9.8641537792703101567472056e-72452394265', '9.8641537792703101567472055694976920744483687020935E-72452394265', 26, 2);
t('1.027989e+401293443271', '1.0279887207E+401293443271', 7, 4);
t('4.76e+44979245', '4.7639E+44979245', 3, 4);
t('-1.7306e+1059755325', '-1.7306315078051716446467E+1059755325', 5, 4);
t('3.9456282632322e+203687', '3.9456282632321519002673617475779957462749297912E+203687', 14, 4);
t('-8.5376063018414796e-534432343020843', '-8.53760630184147960E-534432343020843', 21, 2);
t('8.65224414419867239120564571373e+8606642533', '8.652244144198672391205645713722739150532482412E+8606642533', 30, 2);
t('-6.174e+9', '-6173578265.071', 4, 4);
t('6.793079624623340928072e+7', '67930796.2462334092807242196421600', 22, 5);
t('-2.36373930494803297524865796700721024e+838379', '-2.36373930494803297524865796700721024881625741597833295816323E+838379', 36, 1);
t('-9e+5483611650120', '-9E+5483611650120', 4, 3);
t('1.5e+7', '14349628.01922235388049374147', 2, 0);
t('6.8614e+74393698866798', '6.8614E+74393698866798', 8, 1);
t('-1.831113233533270669228699622e+8406934', '-1.8311132335332706692286996219681430E+8406934', 29, 6);
t('7.714520184016993933542818837124793408006e+2', '771.45201840169939335428188371247934080056704899', 40, 2);
t('-1.07e+6795813709', '-1.0732125537673403265457667040389769358981173800952578892E+6795813709', 3, 5);
t('4.91402e+7112074044', '4.91401973E+7112074044', 7, 0);
t('8.84e+76239602607', '8.841940724E+76239602607', 3, 6);
t('4.794257702528707921549614769559147705541286916e+8949077983', '4.794257702528707921549614769559147705541286916517125838578E+8949077983', 46, 1);
t('-3.14815e+153331637489', '-3.14814925E+153331637489', 6, 5);
t('6.04477481096739e-222583722', '6.04477481096739E-222583722', 18, 4);
t('9.205025903021276187181944366817198e+96711', '9.205025903021276187181944366817198E+96711', 36, 1);
t('9.48094821522133194405126162122334e+351074489623', '9.4809482152213319440512616212233329955405089941555240223386E+351074489623', 33, 0);
t('3.9748340091494161936502395814742749549562853206914631e+3139', '3.97483400914941619365023958147427495495628532069146310E+3139', 55, 4);
tx(function () {new Decimal('12.345').toSD('3')}, ".toSD('3')");
tx(function () {new Decimal('12.345').toSD(new Decimal('3'))}, ".toSD(new Decimal('3'))");
tx(function () {new Decimal('12.345').toSD(NaN)}, ".toSD(NaN)");
tx(function () {new Decimal('12.345').toSD(null)}, ".toSD(null)");
tx(function () {new Decimal('12.345').toSD(NaN)}, ".toSD(NaN)");
tx(function () {new Decimal('12.345').toSD('NaN')}, ".toSD('NaN')");
tx(function () {new Decimal('12.345').toSD([])}, ".toSD([])");
tx(function () {new Decimal('12.345').toSD({})}, ".toSD({})");
tx(function () {new Decimal('12.345').toSD('')}, ".toSD('')");
tx(function () {new Decimal('12.345').toSD(' ')}, ".toSD(' ')");
tx(function () {new Decimal('12.345').toSD('hello')}, ".toSD('hello')");
tx(function () {new Decimal('12.345').toSD('\t')}, ".toSD('\t')");
tx(function () {new Decimal('12.345').toSD(new Date)}, ".toSD(new Date)");
tx(function () {new Decimal('12.345').toSD(new RegExp)}, ".toSD(new RegExp)");
tx(function () {new Decimal('12.345').toSD(7.5)}, ".toSD(7.5)");
tx(function () {new Decimal('12.345').toSD('1.1e1')}, ".toSD('1.1e1')");
tx(function () {new Decimal('12.345').toSD(0, 1)}, ".toSD(0, 1)");
tx(function () {new Decimal('12.345').toSD(1, '2')}, ".toSD(1, '2')");
tx(function () {new Decimal('12.345').toSD(1, 2.3)}, ".toSD(1, 2.3)");
tx(function () {new Decimal('12.345').toSD('0')}, ".toSD('0')");
tx(function () {new Decimal('12.345').toSD('-1')}, ".toSD('-1')");
tx(function () {new Decimal('12.345').toSD(-23)}, ".toSD(-23)");
tx(function () {new Decimal('12.345').toSD(1e9 + 1)}, ".toSD(1e9 + 1)");
tx(function () {new Decimal('12.345').toSD('-0.01')}, ".toSD('-0.01')");
tx(function () {new Decimal('12.345').toSD('-1e-1')}, ".toSD('-1e-1')");
tx(function () {new Decimal('12.345').toSD(Infinity)}, ".toSD(Infinity)");
tx(function () {new Decimal('12.345').toSD('-Infinity')}, ".toSD('-Infinity')");
T.stop();
})();

365
test/modules/toString.js Normal file
View File

@ -0,0 +1,365 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('toString');
function t(expected, n) {
T.assertEqual(expected, new Decimal(n).toString());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('0', 0);
t('0', '0');
t('NaN', NaN);
t('NaN', 'NaN');
t('Infinity', 1/0);
t('Infinity', 'Infinity');
t('1', 1);
t('9', 9);
t('90', 90);
t('90.12', 90.12);
t('0.1', 0.1);
t('0.01', 0.01);
t('0.0123', 0.0123);
t('111111111111111111111', '111111111111111111111');
t('1111111111111111111111', '1111111111111111111111');
t('11111111111111111111111', '11111111111111111111111');
t('0.00001', 0.00001);
t('0.000001', 0.000001);
t('0', -0);
t('0', '-0');
t('-Infinity', -1/0);
t('-Infinity', '-Infinity');
t('-1', -1);
t('-9', -9);
t('-90', -90);
t('-90.12', -90.12);
t('-0.1', -0.1);
t('-0.01', -0.01);
t('-0.0123', -0.0123);
t('-111111111111111111111', '-111111111111111111111');
t('-1111111111111111111111', '-1111111111111111111111');
t('-11111111111111111111111', '-11111111111111111111111');
t('-0.00001', -0.00001);
t('-0.000001', -0.000001);
// Exponential format
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('1e-7', 0.0000001);
t('1.2e-7', 0.00000012);
t('1.23e-7', 0.000000123);
t('1e-8', 0.00000001);
t('1.2e-8', 0.000000012);
t('1.23e-8', 0.0000000123);
t('-1e-7', -0.0000001);
t('-1.2e-7', -0.00000012);
t('-1.23e-7', -0.000000123);
t('-1e-8', -0.00000001);
t('-1.2e-8', -0.000000012);
t('-1.23e-8', -0.0000000123);
t('5.73447902457635174479825134e+14', '573447902457635.174479825134');
t('1.07688e+1', '10.7688');
t('3.171194102379077141557759899307946350455841e+27', '3171194102379077141557759899.307946350455841');
t('4.924353466898191177698653319742594890634579e+37', '49243534668981911776986533197425948906.34579');
t('6.85558243926569397328633907445409866949445343654692955e+18', '6855582439265693973.28633907445409866949445343654692955');
t('1e+0', '1');
t('2.1320000803e+7', '21320000.803');
t('5.0878741e+4', '50878.741');
t('5.1932898288391e+8', '519328982.88391');
t('5.690616778176956027307884725933410349604387915634524e+49', '56906167781769560273078847259334103496043879156345.24');
t('3.25099780528575457273246693147645e+15', '3250997805285754.572732466931476450');
t('3e+0', '3');
t('2.5811494197573291905990947355226e+13', '25811494197573.291905990947355226');
t('5.60372259169833930471746454125e+13', '56037225916983.3930471746454125');
t('1.2615810663732236602461593613783e+7', '12615810.663732236602461593613783');
t('1.4654366449266911507705477499035407722184965108377032e+11', '146543664492.66911507705477499035407722184965108377032');
t('6.4986735507448912857131832908423940757e+38', '649867355074489128571318329084239407570.0');
t('3.6146989180120676857245474944e+3', '3614.6989180120676857245474944');
t('9.928654762302286149994896625074e+4', '99286.54762302286149994896625074');
t('3.46424170787806074650506079e+3', '3464.24170787806074650506079');
t('1.25934313355319666474752550204680303068865719647e+33', '1259343133553196664747525502046803.03068865719647');
t('1.23014105337660651106978059198916100450966081493207e+27', '1230141053376606511069780591.98916100450966081493207');
t('1.386164712267169624993434287237e+23', '138616471226716962499343.4287237');
t('2.66076369930322488334961932e+3', '2660.76369930322488334961932');
t('9.37582568e+4', '93758.2568');
t('1.39853642894726883996875746770529e+28', '13985364289472688399687574677.0529');
t('3.19099e+5', '319099.0');
t('3.04557106798789396303998723e+19', '30455710679878939630.3998723');
t('1.3024612569115368830867934222004329653604418e+9', '1302461256.9115368830867934222004329653604418');
t('2.358787483447172786e+5', '235878.7483447172786');
t('5.10614446965318674547416709785208086304398889160563e+28', '51061444696531867454741670978.5208086304398889160563');
t('1.46685947134456101512731611558e+23', '146685947134456101512731.6115580');
t('3.69960105771344554151928256518906564810300119e+25', '36996010577134455415192825.6518906564810300119');
t('2.68683153074628e+10', '26868315307.4628');
t('2.35656504568492312232737219553793859212e+15', '2356565045684923.12232737219553793859212');
t('7.753292442361215e+14', '775329244236121.5');
t('1.56e+0', '1.56');
t('1.272818730367215461852227991200704e+21', '1272818730367215461852.227991200704');
t('1.13900700292988027871648046839423153789e+7', '11390070.0292988027871648046839423153789');
t('3.3431e+0', '3.3431');
t('1.4546654966819402705e+14', '145466549668194.02705');
t('3.05345735395805567424714891401667575466462830113819e+48', '3053457353958055674247148914016675754664628301138.19');
t('5.1218945854639324441304933666460587e+2', '512.18945854639324441304933666460587');
t('9.95299900896e+5', '995299.9008960');
t('1.21564537151562431991786620635e+0', '1.21564537151562431991786620635');
t('4.016e+1', '40.16');
t('1.86570326e+7', '18657032.6');
t('1.3381001727e+5', '133810.01727');
t('2.639841700687441886800225725227e+12', '2639841700687.441886800225725227');
t('2.45e+0', '2.45');
t('2.8945e+2', '289.45');
t('1.23e+0', '1.23');
t('1.559806666149836070330006415033e+24', '1559806666149836070330006.415033');
t('3.14984566145310751826289711761375061645611777700983e+3', '3149.84566145310751826289711761375061645611777700983');
t('3.0940691333892283249774116223987e+5', '309406.91333892283249774116223987');
t('6.572766274013360381079275191108732606370177179594282e+5', '657276.6274013360381079275191108732606370177179594282');
t('1.470126973337024e+6', '1470126.973337024');
t('5.6499e+2', '564.99');
t('2.8416297367859233303497847667971781197616950846e+28', '28416297367859233303497847667.971781197616950846');
t('2.1364951568189836563102481625533538320051163977e+41', '213649515681898365631024816255335383200511.63977');
t('8.76108618687537137080904679797e+19', '87610861868753713708.0904679797');
t('6.27683573474251182408654509953633505286e+6', '6276835.73474251182408654509953633505286');
t('8.91411e+0', '8.91411');
t('9.034542832410912578330021146413119399e+28', '90345428324109125783300211464.13119399');
t('7.026094393430852002585511641212897686956090955e+39', '7026094393430852002585511641212897686956.090955');
t('1.8812221093491505758565988678062e+11', '188122210934.91505758565988678062');
t('9.435538492497050138580201734902181057468044875e+43', '94355384924970501385802017349021810574680448.75');
t('5.36793419620790391866461e+20', '536793419620790391866.461');
t('2.315089265590404012562599592854156357726817712e+26', '231508926559040401256259959.2854156357726817712');
t('7.499170741828885273030006066196546588710962e+17', '749917074182888527.3030006066196546588710962');
t('3.3962128305986e+5', '339621.28305986');
t('8.17980456510031304e+9', '8179804565.10031304');
t('4.394575876858124185382e+13', '43945758768581.24185382');
t('7.881617323629751701107428e+9', '7881617323.629751701107428');
t('4.89e+0', '4.89');
t('9.85209894663520857685703881781194082356123765e+39', '9852098946635208576857038817811940823561.23765');
t('6.849329685e+5', '684932.9685');
t('2.8262252277815736355279617243060700437627773361e+7', '28262252.277815736355279617243060700437627773361');
t('1.503736721902e+9', '1503736721.902');
t('2.65213505469049775997232325076980590625670234690917845e+41', '265213505469049775997232325076980590625670.234690917845');
t('4.23752645959719196604760963802412828187442060555521e+2', '423.752645959719196604760963802412828187442060555521');
t('9.023159535576504097005203913521871601640521009e+36', '9023159535576504097005203913521871601.640521009');
t('4.69339457186380276410136272120035011198438772754725e+14', '469339457186380.276410136272120035011198438772754725');
t('1.2819429130391792511503973184804508867728894e+6', '1281942.9130391792511503973184804508867728894');
t('1.9778e+3', '1977.8');
t('2.456680359828937628024631306792185367572610021e+43', '24566803598289376280246313067921853675726100.21');
t('5.25389225018085571689046925802871155628e+1', '52.5389225018085571689046925802871155628');
t('1.733700532107e+8', '173370053.2107');
t('1.9561099921e+5', '195610.99921');
t('3.3409e+2', '334.09');
t('6.09858715556186e+0', '6.09858715556186');
t('3.20634106832106387482375790792609337383007782520694e+24', '3206341068321063874823757.90792609337383007782520694');
t('1.46347126003930100207988814e+20', '146347126003930100207.98881400');
t('2.717780449744210117995586561524987067807146882e+43', '27177804497442101179955865615249870678071468.82');
t('2.86757572635270377540170639151e+22', '28675757263527037754017.0639151');
t('1.3488325541508602487577920722101277063863557818e+14', '134883255415086.02487577920722101277063863557818');
t('1.96013732736436392e+13', '19601373273643.6392');
t('4.798185890466e+2', '479.8185890466');
t('1.696622337138949329874242519485119916519994150606e+39', '1696622337138949329874242519485119916519.994150606');
t('5.50000572984970761183142593570950897913860587074643e+13', '55000057298497.0761183142593570950897913860587074643');
t('4.9e+1', '49');
t('2.353405108244768666141e+9', '2353405108.2447686661410');
t('1.237978927714857736527530290155529e+0', '1.237978927714857736527530290155529');
t('5.54113012e+1', '55.411301200');
t('1.639709023131e+11', '163970902313.1');
t('2.15324060127001207725970506357881e+19', '21532406012700120772.5970506357881');
t('2.373532121822929762731612214095513784533409e+29', '237353212182292976273161221409.5513784533409');
t('4.5883026736677354807679611737881799804e+16', '45883026736677354.807679611737881799804');
t('2.5996714820346689325468319633061e+21', '2599671482034668932546.8319633061');
t('8.22641928e+6', '8226419.280');
t('2.56006014528479284199702229871263269e+20', '256006014528479284199.702229871263269');
t('4.301260132991159779386275268219519443685e+24', '4301260132991159779386275.268219519443685');
t('1.052721790360165649330888881e+22', '10527217903601656493308.88881');
t('6.85257703973809064426443728e+0', '6.85257703973809064426443728');
t('1.341206836e+5', '134120.6836');
t('1.293696083809745995580141432072678134217648017629e+25', '12936960838097459955801414.32072678134217648017629');
t('9.81886611183e+9', '9818866111.83');
t('1.3e+1', '13');
t('2.185212134168411755342025405260683400574952243371e+1', '21.8521213416841175534202540526068340057495224337100');
t('5.09812942277266e+1', '50.9812942277266');
t('1.15841228150473459450904593187073359993e+37', '11584122815047345945090459318707335999.3');
t('2.946408e+1', '29.46408');
t('7.8843253757257e+6', '7884325.3757257');
t('4.149829532631829e+7', '41498295.32631829');
t('9.76844406944663415436782518894675931581135161845733e+46', '97684440694466341543678251889467593158113516184.5733');
t('1.320634109357604978481e+7', '13206341.09357604978481');
t('1.2300117044692162331376535732386421937e+8', '123001170.44692162331376535732386421937');
t('1.79343822239530391558796001578394154846951511735e+42', '1793438222395303915587960015783941548469515.11735');
t('3.46227335968923941657647562338569e+7', '34622733.5968923941657647562338569');
t('3.6081901133629252234652167e+18', '3608190113362925223.4652167');
t('3.41769614577210353834283168068494e+24', '3417696145772103538342831.68068494');
t('1.036693895e+8', '103669389.5');
t('9.840862048026534392868878603161623504069221701e+27', '9840862048026534392868878603.161623504069221701');
t('2.56437211238605e+10', '25643721123.86050');
t('2.645333616435501e+6', '2645333.616435501');
t('3.75834254646606787747061360998e+1', '37.5834254646606787747061360998');
t('1.21582101247e+6', '1215821.01247');
t('5.43e+1', '54.3');
t('3.1461380403028457753654142032015e+27', '3146138040302845775365414203.2015');
t('2.73039e+4', '27303.9');
t('3.349112077000398203735762417e+25', '33491120770003982037357624.170');
t('2.293912475527946909960963698602754526495697363e+31', '22939124755279469099609636986027.54526495697363');
t('7.800578368e+8', '780057836.8');
t('3.503304265046835170500513083432983735273e+28', '35033042650468351705005130834.32983735273');
t('6.521027589563589728e+9', '6521027589.563589728');
t('1.26604818273232e+3', '1266.04818273232');
t('4.5844253800756959854340115e+7', '45844253.800756959854340115');
t('2.5103887704609158215979351198183e+20', '251038877046091582159.79351198183');
t('6.5170765018089001398157674630438543e+17', '651707650180890013.98157674630438543');
t('7.85679659655762637941070216699747e+18', '7856796596557626379.41070216699747');
t('6.55113755834849587145e+18', '6551137558348495871.45');
t('1.37856413555592382324487860882977704999616e+32', '137856413555592382324487860882977.704999616');
t('7.51530486314140193e+5', '751530.486314140193');
t('1.3712642461229590011e+7', '13712642.4612295900110');
t('8.945222111405724e+2', '894.5222111405724');
t('1.74501389497524149414213254563953197394499747444317e+44', '174501389497524149414213254563953197394499747.444317');
t('7.1583294041845987824307132e+11', '715832940418.45987824307132');
t('1.282007923703783860923747442697572540049e+13', '12820079237037.83860923747442697572540049');
t('5.660625174793381639446229222e+11', '566062517479.3381639446229222');
t('2.094745267e+4', '20947.45267');
t('8.4497877437844686621097450218313191175e+13', '84497877437844.6866210974502183131911750');
t('1.707217105197425488000493702652714920318758323999364e+23', '170721710519742548800049.3702652714920318758323999364');
t('2.5487434814078948112667918801256335353406914111636153e+36', '2548743481407894811266791880125633535.3406914111636153');
t('7.975944255792483246376368330364e+8', '797594425.5792483246376368330364');
t('1.1038710051127692465453332862048e+20', '110387100511276924654.53332862048');
t('2.0214122542287381656860062564183697682e+13', '20214122542287.381656860062564183697682');
t('7.853012025112e+4', '78530.12025112');
t('7.97061651146928e+3', '7970.61651146928');
t('1.5712956919727392305361179349388e+10', '15712956919.727392305361179349388');
t('8.2480059e+3', '8248.0059');
t('2.71929146422591231877279340940781443961397491e+19', '27192914642259123187.7279340940781443961397491');
t('2.131e+2', '213.10');
t('5.53443299017925367e+6', '5534432.99017925367');
t('9.0599636453e+8', '905996364.53');
t('2.86841011915001378943e+0', '2.86841011915001378943');
t('3.50691916034642635201767965866239485795145676493e+28', '35069191603464263520176796586.6239485795145676493');
t('1.20268235416561427028396813141142129291e+18', '1202682354165614270.283968131411421292910');
t('4.8878729e+4', '48878.7290');
t('9.04344910891e+4', '90434.4910891');
t('3.87232843764031e+2', '387.232843764031');
t('2.246212201353343e+11', '224621220135.33430');
t('4.92916234816086643529027167741689023e+4', '49291.6234816086643529027167741689023');
t('2.1773818234639052045922630496e+22', '21773818234639052045922.630496');
t('4.78705362683815125848e+0', '4.787053626838151258480');
t('2.700762078698436846755198719005e+28', '27007620786984368467551987190.05');
t('3.04897901998664513240359358574664525651334171e+36', '3048979019986645132403593585746645256.51334171');
t('3.807300704307638993582e+18', '3807300704307638993.582');
t('7.9846840795076707340124614425632613353204e+3', '7984.6840795076707340124614425632613353204');
t('6.69918558928e+4', '66991.8558928');
t('5.11e+1', '51.1');
t('1.8e+1', '18');
t('2.629676971e+2', '262.9676971');
t('6.8402048967767212280354493672372347369800788279670097e+39', '6840204896776721228035449367237234736980.0788279670097');
t('4.684145127602661593941009299096573092581e+21', '4684145127602661593941.009299096573092581');
t('1.3010133600355313564757759338788842e+18', '1301013360035531356.4757759338788842');
t('1.58527974113934732993372979240170059e+30', '1585279741139347329933729792401.70059');
t('1.8249338722142728063286e+2', '182.49338722142728063286');
t('1.5941e+0', '1.59410');
t('2.0337546838170082473539926326926478252219475e+29', '203375468381700824735399263269.26478252219475');
t('4.626173e+3', '4626.173');
t('6.04857e+0', '6.04857');
t('9.55039030589038069713466331e+0', '9.55039030589038069713466331');
t('3.13977842e+6', '3139778.42');
t('4.4046554138751e+10', '44046554138.751');
t('2.27133088062335544441002965096e+25', '22713308806233554444100296.5096');
t('1.72895143e+4', '17289.5143');
t('2.59665963383099309886519729836757e+20', '259665963383099309886.5197298367570');
t('5.42804375404301025317704270939778493719619031067122726e+24', '5428043754043010253177042.70939778493719619031067122726');
t('4.0526054186532354119711729303068171063825508e+2', '405.26054186532354119711729303068171063825508');
t('1.26960267394273418410687782475849e+9', '1269602673.94273418410687782475849');
t('5.657206212494798707700546288522044895183104747814298e+7', '56572062.12494798707700546288522044895183104747814298');
t('4.80834664047405196104320584899449259286e+21', '4808346640474051961043.20584899449259286');
t('5.6639294733687553228095e+12', '5663929473368.7553228095');
t('3.08469899797006019074738182718775120203832280411e+44', '308469899797006019074738182718775120203832280.4110');
t('6.7324018330891115163882850963905830707247414517739e+20', '673240183308911151638.82850963905830707247414517739');
t('7.8e+1', '78');
t('3.7511576e+4', '37511.576');
t('4.9744737445922007872559411117007e+20', '497447374459220078725.59411117007');
t('1.4264855114407053894401398660016825255242638071603e+2', '142.64855114407053894401398660016825255242638071603');
t('1.7972e+1', '17.972');
t('1.08223075909551421423442320791403363148864e+12', '1082230759095.51421423442320791403363148864');
t('1.27992032328728568e+16', '12799203232872856.8');
t('3.23410998756876789482263723951851692122375679e+9', '3234109987.56876789482263723951851692122375679');
t('8.309058187826413886051933894555524364e+5', '830905.8187826413886051933894555524364');
t('5.9126904485324084868266487306831291316268437628598e+40', '59126904485324084868266487306831291316268.437628598');
t('3.579918283412251816470339246643e+16', '35799182834122518.16470339246643');
t('8.292403288e+1', '82.92403288');
t('7.39431e+2', '739.431');
t('3.880259e+2', '388.0259');
t('8.356612898392420429137009991722851e+18', '8356612898392420429.137009991722851');
t('5.395903069e+4', '53959.03069');
t('2.084656696443025813e+12', '2084656696443.025813');
t('7.54671420639507228408101673007042651462774881888e+46', '75467142063950722840810167300704265146277488188.8');
t('6.9e+1', '69');
t('8.921e+2', '892.10');
t('2.51196408e+4', '25119.6408');
t('4.2502325992166027236666111862782e+15', '4250232599216602.7236666111862782');
t('1.48181688637265610577148846528720697801886e+17', '148181688637265610.577148846528720697801886');
t('6.578849006577789439801702e+0', '6.578849006577789439801702');
t('4.346905625146927213132990652e+22', '43469056251469272131329.90652');
t('5.5037893e+0', '5.5037893');
t('2.47731675267438120023934691987e+15', '2477316752674381.20023934691987');
t('3.37487366652276710575333974697197457e+9', '3374873666.52276710575333974697197457');
t('1.0385387059229329627650733271e+0', '1.0385387059229329627650733271');
t('9.83004944893186643985967600066862369294062e+17', '983004944893186643.985967600066862369294062');
t('4.24581658127100743607231740518633563667839856744e+26', '424581658127100743607231740.518633563667839856744');
t('3.14222253457223322124561584676953981561133e+2', '314.222253457223322124561584676953981561133');
t('1.1553833141891499623566322265502695096447390786748e+48', '1155383314189149962356632226550269509644739078674.8');
t('5.2811e+1', '52.811');
t('9.925202445922857021945001443270353221818473047344e+2', '992.5202445922857021945001443270353221818473047344');
t('1.5758941e+4', '15758.9410');
t('6.6630010328564980059488916358767e+30', '6663001032856498005948891635876.7');
t('1.49898377473153728100588907982263779724221092732531e+44', '149898377473153728100588907982263779724221092.732531');
t('4.175238908185616536855e+20', '417523890818561653685.5');
t('1.192838736272799853174021036238e+21', '1192838736272799853174.021036238');
t('1.145038e+3', '1145.038');
t('4.0973786626728889384598402998014750474268e+9', '4097378662.6728889384598402998014750474268');
t('5.5038104e+4', '55038.104');
t('6.83895535917805849194871290958068199407518e+2', '683.895535917805849194871290958068199407518');
t('2.9716066182e+0', '2.9716066182');
t('1e+0', '1');
t('1.78063428481384259205331358231117935e+0', '1.780634284813842592053313582311179350');
t('6.277714976103425712837719e+22', '62777149761034257128377.1900');
t('1.37376909692642287134486582232200547809845780076e+26', '137376909692642287134486582.232200547809845780076');
t('7.0255659498942180908195e+16', '70255659498942180.908195');
t('1.36758412477e+6', '1367584.12477');
t('2.8993016541323392639291954727329719281958174e+23', '289930165413233926392919.54727329719281958174');
t('2.44e+0', '2.44');
t('5.39870374073212675286058196342904027304008232e+40', '53987037407321267528605819634290402730400.8232');
t('6.4507160654825e+9', '6450716065.4825');
t('1.21664e+3', '1216.64');
t('3.13108416362400780440861428855476299376486503e+0', '3.13108416362400780440861428855476299376486503');
t('7.2960499529336221198242592384915903149558006256202995e+17', '729604995293362211.98242592384915903149558006256202995');
t('5.67239328846178836850536139916737284448973e+0', '5.67239328846178836850536139916737284448973');
t('7.20020305957519743064e+3', '7200.203059575197430640');
t('1.85115423780064073715032545790701546649748120114e+27', '1851154237800640737150325457.90701546649748120114');
t('1.25021250836778893386687012660759710902e+21', '1250212508367788933866.87012660759710902');
t('2.3323707491301665555664068537483355865980611e+25', '23323707491301665555664068.5374833558659806110');
t('2.5088131581298507401113299236e+4', '25088.131581298507401113299236');
t('9.612326850563943155774866e+17', '961232685056394315.5774866');
t('1.54114517176248297154289225338049499367447824e+22', '15411451717624829715428.9225338049499367447824');
t('5.22e+0', '5.22');
t('4.04698305476309533783897e+21', '4046983054763095337838.97');
t('2.620876536774240989563272117908814902188002596311e+24', '2620876536774240989563272.117908814902188002596311');
t('1.7290754650750439926458970782158e+10', '17290754650.750439926458970782158');
t('8.570789332248e+6', '8570789.332248');
t('1.21e+1', '12.1');
t('9.749134061639126502181192178140679940393318673720443e+45', '9749134061639126502181192178140679940393318673.720443');
t('1.26878e+5', '126878.0');
t('1.2391599841950849289559651456348e+9', '1239159984.1950849289559651456348');
t('1.72220118427662724614289256133342842086e+22', '17222011842766272461428.9256133342842086');
t('1.512063585971680294584184272035496e+15', '1512063585971680.294584184272035496');
T.stop();
})();

131
test/modules/trunc.js Normal file
View File

@ -0,0 +1,131 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('trunc');
function t(expected, n) {
T.assertEqual(expected, Decimal.trunc(n).valueOf());
T.assertEqual(expected, new Decimal(n).trunc().valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -1e3,
toExpPos: 1e3,
minE: -9e15,
maxE: 9e15
});
t('0', 0);
t('-0', -0);
t('0', '0.000');
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);
t('1', '1.9999999999');
t('-1', '-1.9999999999');
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('-4542227860', '-4542227860.9511298545226');
t('2416872281', '2416872281.963955669484225137349193306323379254936827');
t('-757684868752087594264588207655', '-757684868752087594264588207655.27838048392835556');
t('-438798503526', '-438798503526.2317623894721299587561697');
t('801625782231888715214665', '801625782231888715214665');
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('-6581532150677269472829', '-6581532150677269472829.38194951340848938896000325718062365494');
t('-131279182164804751', '-131279182164804751.430589952021038264');
t('2949426983040959', '2949426983040959.8911208825380208568451907');
t('25166', '25166.125888418871654557352055849116604612621573251770362');
t('4560569286495', '4560569286495.98300685103599898554605198');
t('13', '13.763105480576616251068323541559825687');
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.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.000000090358252973411013592234');
t('276312604693909858427', '276312604693909858427.21965306055697011390137926559');
t('0', '0.0000252');
Decimal.toExpNeg = -100;
Decimal.toExpPos = 100;
t('-0', -1e-308);
t('-1e+308', -1e308);
t('2.1e+308', '2.1e308');
t('-0', '-1e-999');
t('0', '1e-999');
t('0', '1e-9000000000000000');
t('-0', '-1e-9000000000000000');
t('-0', '-9.9e-9000000000000001'); // underflow to zero
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');
T.stop();
})();

68
test/modules/valueOf.js Normal file
View File

@ -0,0 +1,68 @@
if (typeof T === 'undefined') require('../setup');
(function () {
T('valueOf');
function t(expected, n) {
T.assertEqual(expected, new Decimal(n).valueOf());
}
Decimal.config({
precision: 20,
rounding: 4,
toExpNeg: -9e15,
toExpPos: 9e15,
minE: -9e15,
maxE: 9e15
});
t('0', 0);
t('0', '0');
t('NaN', NaN);
t('NaN', 'NaN');
t('Infinity', 1/0);
t('Infinity', 'Infinity');
t('1', 1);
t('9', 9);
t('90', 90);
t('90.12', 90.12);
t('0.1', 0.1);
t('0.01', 0.01);
t('0.0123', 0.0123);
t('111111111111111111111', '111111111111111111111');
t('0.00001', 0.00001);
t('-0', -0);
t('-0', '-0');
t('-Infinity', -1/0);
t('-Infinity', '-Infinity');
t('-1', -1);
t('-9', -9);
t('-90', -90);
t('-90.12', -90.12);
t('-0.1', -0.1);
t('-0.01', -0.01);
t('-0.0123', -0.0123);
t('-111111111111111111111', '-111111111111111111111');
t('-0.00001', -0.00001);
// Exponential format
Decimal.toExpNeg = Decimal.toExpPos = 0;
t('1e-7', 0.0000001);
t('1.23e-7', 0.000000123);
t('1.2e-8', 0.000000012);
t('-1e-7', -0.0000001);
t('-1.23e-7', -0.000000123);
t('-1.2e-8', -0.000000012);
t('5.73447902457635174479825134e+14', '573447902457635.174479825134');
t('1.07688e+1', '10.7688');
t('3.171194102379077141557759899307946350455841e+27', '3171194102379077141557759899.307946350455841');
t('4.924353466898191177698653319742594890634579e+37', '49243534668981911776986533197425948906.34579');
t('6.85558243926569397328633907445409866949445343654692955e+18', '6855582439265693973.28633907445409866949445343654692955');
t('1e+0', '1');
T.stop();
})();

View File

@ -1,471 +0,0 @@
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;

View File

@ -1,489 +0,0 @@
/*
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
*/

View File

@ -1,771 +0,0 @@
<!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>

View File

@ -1,205 +0,0 @@
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

View File

@ -1,61 +0,0 @@
/*
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);

Some files were not shown because too many files have changed in this diff Show More