You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Was using https://github.com/felixge/node-mysql with supportBigNumbers:true and bigNumberStrings:false, but found that I would still get the tooManyDigits error occasionally:
number type has more than 15 significant digits
After digging in, I was amused to find that mysql is actually using bignumber.js under the hood, but is calculating more precisely when to switch from JS Number to a string. They check the binary representation to see if a number is "too big" to be represented accurately, which makes sense because they have to twiddle bits anyway come from MySQL.
I was wondering if it would make sense in bignumber.js to add a simple test to the constructor to see, if the number is an integer, whether the number is (val < Number.MAX_VALUE && val > Number.MIN_VALUE)? This would allow a wider range of "safe" numbers to be created without throwing an error (in particular, all the 16-digit integers < 9007199254740992 are okay in Javascript).
The text was updated successfully, but these errors were encountered:
Was using https://github.com/felixge/node-mysql with
supportBigNumbers:true
andbigNumberStrings:false
, but found that I would still get thetooManyDigits
error occasionally:After digging in, I was amused to find that
mysql
is actually usingbignumber.js
under the hood, but is calculating more precisely when to switch from JS Number to a string. They check the binary representation to see if a number is "too big" to be represented accurately, which makes sense because they have to twiddle bits anyway come from MySQL.I was wondering if it would make sense in
bignumber.js
to add a simple test to the constructor to see, if the number is an integer, whether the number is(val < Number.MAX_VALUE && val > Number.MIN_VALUE)
? This would allow a wider range of "safe" numbers to be created without throwing an error (in particular, all the 16-digit integers < 9007199254740992 are okay in Javascript).The text was updated successfully, but these errors were encountered: