peterolson / BigInteger.js

An arbitrary length integer library for Javascript
The Unlicense
1.12k stars 187 forks source link

In node.j my number has commas #204

Closed benzmuircroft closed 4 years ago

benzmuircroft commented 4 years ago

In the browser

console.log(bigInt('9999999999999999990').add('1').value.toString());

9999999999999999991

In Node.js

console.log(bigInt('9999999999999999990').add('1').value.toString());

9999991,9999999,99999
Happypig375 commented 4 years ago

value is the internal representation. Browsers that implement bigInt will have a native value. In contrast, when bigInt is not natively implemented, an array is used to polyfill. This behavior is expected.

benzmuircroft commented 4 years ago

so i should value.reverse().join('')

?

Happypig375 commented 4 years ago

Use toString() without .value

benzmuircroft commented 4 years ago

k thanks