From 8c34396eb4a08344ac9332b4eb9dcc00bc147f39 Mon Sep 17 00:00:00 2001 From: Doron Pagot Date: Mon, 18 Feb 2019 22:19:09 +0200 Subject: [PATCH] Allow { s: null, e: null, c: null } (NaN) --- bignumber.js | 2 +- test/methods/BigNumber.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bignumber.js b/bignumber.js index a0debf3..ca980d9 100644 --- a/bignumber.js +++ b/bignumber.js @@ -196,7 +196,7 @@ // Duplicate. if (n instanceof BigNumber - || (n != null && n.s != null && n.e != null && n.c != null)) { + || (n && typeof n.s !== 'undefined' && typeof n.e !== 'undefined' && typeof n.c !== 'undefined')) { x.s = n.s; x.e = n.e; x.c = (n = n.c) ? n.slice() : n; diff --git a/test/methods/BigNumber.js b/test/methods/BigNumber.js index f1c70cc..3bbac1b 100644 --- a/test/methods/BigNumber.js +++ b/test/methods/BigNumber.js @@ -201,6 +201,7 @@ Test('bigNumber', function () { t('100002222.2222333322', new BigNumber({ s: 1, e: 8, c: [100002222, 22223333220000] }).toString()) t('7777777777.123123123', new BigNumber({ s: 1, e: 9, c: [7777777777, 12312312300000] }).toString()) + t('NaN', new BigNumber({ s: null, e: null, c: null }).toString()) // Base-conversion tests