Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion decimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
3 changes: 2 additions & 1 deletion decimal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
3 changes: 2 additions & 1 deletion test/modules/sum.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down