math - Why can't I get big number libraries for javascript to work? -
looking library work large numbers on javascript (bigger 2^53) checked couple of questions (javascript large number library? , is there bignum library javascript?) , tinkered little bit javascript-bignum.js , big.js, thing unable represent odd numbers, since both
big(9007199254740995);
and
schemenumber.fn["string->number"](9007199254740995);
return
9007199254740996
rather than
9007199254740995
as expect.
so, doing wrong? or there's no way represent large odd numbers?
when
big(9007199254740995)
you not giving bignum library chance! numeric literal first parsed pure js, in number isn't representable. can see with
window.alert(9007199254740995);
which alerts 9007199254740996
.
in order let chosen bignum library represent number, need pass string, example:
big('9007199254740995')
should exact number, bignum.
Comments
Post a Comment