1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2026-01-22 16:59:27 +00:00
This commit is contained in:
Hunter Wilhelm 2025-12-20 16:44:40 -07:00 committed by GitHub
commit 5d82744250
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View File

@ -4861,7 +4861,8 @@
function sum() { function sum() {
var i = 0, var i = 0,
args = arguments, args = arguments,
x = new this(args[i]); firstArg = args[i],
x = new this(firstArg === undefined ? 0 : firstArg);
external = false; external = false;
for (; x.s && ++i < args.length;) x = x.plus(args[i]); for (; x.s && ++i < args.length;) x = x.plus(args[i]);

View File

@ -4856,7 +4856,8 @@ function sub(x, y) {
function sum() { function sum() {
var i = 0, var i = 0,
args = arguments, args = arguments,
x = new this(args[i]); firstArg = args[i],
x = new this(firstArg === undefined ? 0 : firstArg);
external = false; external = false;
for (; x.s && ++i < args.length;) x = x.plus(args[i]); for (; x.s && ++i < args.length;) x = x.plus(args[i]);

View File

@ -16,6 +16,7 @@ T('sum', function () {
t(11, -11); t(11, -11);
t(1, '2', new Decimal(3), new Decimal('4'), -10); t(1, '2', new Decimal(3), new Decimal('4'), -10);
t(new Decimal(-10), '9', new Decimal(0.01), 0.99); t(new Decimal(-10), '9', new Decimal(0.01), 0.99);
t();
expected = new Decimal(10); expected = new Decimal(10);