mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2024-10-27 20:34:12 +00:00
v5.0.1
This commit is contained in:
parent
c39ab46529
commit
b8b2ed7a2b
@ -1,3 +1,8 @@
|
|||||||
|
####5.0.1
|
||||||
|
* 28/01/2015
|
||||||
|
* Bugfix: #20 cos mutates value.
|
||||||
|
* Add pi info to docs.
|
||||||
|
|
||||||
####5.0.0
|
####5.0.0
|
||||||
* 25/01/2016
|
* 25/01/2016
|
||||||
* Added trigonometric functions and `cubeRoot` method.
|
* Added trigonometric functions and `cubeRoot` method.
|
||||||
@ -5,6 +10,7 @@
|
|||||||
* Added `toBinary`, `toHexadecimal` and `toOctal` methods.
|
* Added `toBinary`, `toHexadecimal` and `toOctal` methods.
|
||||||
* Added `isPositive` method.
|
* Added `isPositive` method.
|
||||||
* Removed the 15 significant digit limit for numbers.
|
* Removed the 15 significant digit limit for numbers.
|
||||||
|
* `toFraction` now returns an array of two Decimals, not two strings.
|
||||||
* String values containing whitespace or a plus sign are no longer accepted.
|
* String values containing whitespace or a plus sign are no longer accepted.
|
||||||
* `valueOf` now returns `'-0'` for minus zero.
|
* `valueOf` now returns `'-0'` for minus zero.
|
||||||
* `comparedTo` now returns `NaN` not `null` for comparisons with `NaN`.
|
* `comparedTo` now returns `NaN` not `null` for comparisons with `NaN`.
|
||||||
|
45
decimal.js
45
decimal.js
@ -1,10 +1,10 @@
|
|||||||
/*! decimal.js v5.0.0 https://github.com/MikeMcl/decimal.js/LICENCE */
|
/*! decimal.js v5.0.1 https://github.com/MikeMcl/decimal.js/LICENCE */
|
||||||
;(function (globalScope) {
|
;(function (globalScope) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* decimal.js v5.0.0
|
* decimal.js v5.0.1
|
||||||
* An arbitrary-precision Decimal type for JavaScript.
|
* An arbitrary-precision Decimal type for JavaScript.
|
||||||
* https://github.com/MikeMcl/decimal.js
|
* https://github.com/MikeMcl/decimal.js
|
||||||
* Copyright (c) 2016 Michael Mclaughlin <M8ch88l@gmail.com>
|
* Copyright (c) 2016 Michael Mclaughlin <M8ch88l@gmail.com>
|
||||||
@ -413,17 +413,17 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
P.decimalPlaces = P.dp = function () {
|
P.decimalPlaces = P.dp = function () {
|
||||||
var v,
|
var w,
|
||||||
d = this.d,
|
d = this.d,
|
||||||
n = NaN;
|
n = NaN;
|
||||||
|
|
||||||
if (d) {
|
if (d) {
|
||||||
v = d.length - 1;
|
w = d.length - 1;
|
||||||
n = (v - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
||||||
|
|
||||||
// Subtract the number of trailing zeros of the last number.
|
// Subtract the number of trailing zeros of the last word.
|
||||||
v = d[v];
|
w = d[w];
|
||||||
if (v) for (; v % 10 == 0; v /= 10) n--;
|
if (w) for (; w % 10 == 0; w /= 10) n--;
|
||||||
if (n < 0) n = 0;
|
if (n < 0) n = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3089,7 +3089,7 @@
|
|||||||
// they had leading zeros)
|
// they had leading zeros)
|
||||||
// j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
|
// j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
|
||||||
|
|
||||||
// Get the length of the first word of the coefficient array xd.
|
// Get the length of the first word of the digits array xd.
|
||||||
for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++;
|
for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++;
|
||||||
i = sd - digits;
|
i = sd - digits;
|
||||||
|
|
||||||
@ -3326,8 +3326,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is
|
* Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an
|
||||||
* an integer of type number.
|
* integer of type number.
|
||||||
*
|
*
|
||||||
* Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`.
|
* Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`.
|
||||||
*
|
*
|
||||||
@ -3337,7 +3337,7 @@
|
|||||||
r = new Ctor(ONE),
|
r = new Ctor(ONE),
|
||||||
|
|
||||||
// Max n of 9007199254740991 takes 53 loop iterations.
|
// Max n of 9007199254740991 takes 53 loop iterations.
|
||||||
// Maximum coefficient length; leaves [28, 34] guard digits.
|
// Maximum digits array length; leaves [28, 34] guard digits.
|
||||||
k = Math.ceil(pr / LOG_BASE + 4);
|
k = Math.ceil(pr / LOG_BASE + 4);
|
||||||
|
|
||||||
external = false;
|
external = false;
|
||||||
@ -3675,7 +3675,7 @@
|
|||||||
// Transform base
|
// Transform base
|
||||||
|
|
||||||
// e is the base 10 exponent.
|
// e is the base 10 exponent.
|
||||||
// i is where to slice str to get the first word of the coefficient array.
|
// i is where to slice str to get the first word of the digits array.
|
||||||
i = (e + 1) % LOG_BASE;
|
i = (e + 1) % LOG_BASE;
|
||||||
if (e < 0) i += LOG_BASE;
|
if (e < 0) i += LOG_BASE;
|
||||||
|
|
||||||
@ -3875,8 +3875,7 @@
|
|||||||
pi = getPi(Ctor, Ctor.precision, 1),
|
pi = getPi(Ctor, Ctor.precision, 1),
|
||||||
halfPi = pi.times(HALF);
|
halfPi = pi.times(HALF);
|
||||||
|
|
||||||
x = Ctor(x);
|
x = x.abs();
|
||||||
x.s = 1;
|
|
||||||
|
|
||||||
if (x.lte(halfPi)) {
|
if (x.lte(halfPi)) {
|
||||||
quadrant = isNeg ? 4 : 1;
|
quadrant = isNeg ? 4 : 1;
|
||||||
@ -3899,10 +3898,7 @@
|
|||||||
quadrant = isOdd(t) ? (isNeg ? 1 : 4) : (isNeg ? 3 : 2);
|
quadrant = isOdd(t) ? (isNeg ? 1 : 4) : (isNeg ? 3 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = x.minus(pi);
|
return x.minus(pi).abs();
|
||||||
x.s = 1;
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4373,7 +4369,6 @@
|
|||||||
* Return a new Decimal instance.
|
* Return a new Decimal instance.
|
||||||
*
|
*
|
||||||
* v {number|string|Decimal} A numeric value.
|
* v {number|string|Decimal} A numeric value.
|
||||||
* [b] {number} The base of n. Integer, 2 to 64 inclusive.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function Decimal(v) {
|
function Decimal(v) {
|
||||||
@ -4776,9 +4771,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and
|
* Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with
|
||||||
* with `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if
|
* `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros
|
||||||
* trailing zeros are produced).
|
* are produced).
|
||||||
*
|
*
|
||||||
* [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive.
|
* [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive.
|
||||||
*
|
*
|
||||||
@ -5015,7 +5010,9 @@
|
|||||||
|
|
||||||
// AMD.
|
// AMD.
|
||||||
if (typeof define == 'function' && define.amd) {
|
if (typeof define == 'function' && define.amd) {
|
||||||
define(function () { return Decimal; });
|
define(function () {
|
||||||
|
return Decimal;
|
||||||
|
});
|
||||||
|
|
||||||
// Node and other environments that support module.exports.
|
// Node and other environments that support module.exports.
|
||||||
} else if (typeof module != 'undefined' && module.exports) {
|
} else if (typeof module != 'undefined' && module.exports) {
|
||||||
|
6
decimal.min.js
vendored
6
decimal.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "decimal.js",
|
"name": "decimal.js",
|
||||||
"description": "An arbitrary-precision Decimal type for JavaScript.",
|
"description": "An arbitrary-precision Decimal type for JavaScript.",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
"precision",
|
"precision",
|
||||||
@ -28,6 +28,6 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ./test/test.js",
|
"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 */\""
|
"build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v5.0.1 https://github.com/MikeMcl/decimal.js/LICENCE */\""
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user