mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2026-01-20 07:49:24 +00:00
Fixes FIX-207: enables Decimal.sum(...[]) to return 0 instead throwing an error
This commit is contained in:
parent
1a6e845004
commit
df3f232448
@ -4861,7 +4861,8 @@
|
||||
function sum() {
|
||||
var i = 0,
|
||||
args = arguments,
|
||||
x = new this(args[i]);
|
||||
firstArg = args[i],
|
||||
x = new this(firstArg === undefined ? 0 : firstArg);
|
||||
|
||||
external = false;
|
||||
for (; x.s && ++i < args.length;) x = x.plus(args[i]);
|
||||
|
||||
@ -4856,7 +4856,8 @@ function sub(x, y) {
|
||||
function sum() {
|
||||
var i = 0,
|
||||
args = arguments,
|
||||
x = new this(args[i]);
|
||||
firstArg = args[i],
|
||||
x = new this(firstArg === undefined ? 0 : firstArg);
|
||||
|
||||
external = false;
|
||||
for (; x.s && ++i < args.length;) x = x.plus(args[i]);
|
||||
|
||||
@ -16,7 +16,8 @@ T('sum', function () {
|
||||
t(11, -11);
|
||||
t(1, '2', new Decimal(3), new Decimal('4'), -10);
|
||||
t(new Decimal(-10), '9', new Decimal(0.01), 0.99);
|
||||
|
||||
t();
|
||||
|
||||
expected = new Decimal(10);
|
||||
|
||||
t('10');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user