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
{{ message }}
Repository navigation
Options Which Help Support Arbitrary Precision Arithmetic
Bill Davidson edited this page Sep 10, 2016
·
2 revisions
Javascript stores all numbers as 64-bit floating point but there are several Javascript packages to support arbitrary precision arithmetic so that 64-bit floating point doesn't have to be a limit on your code.
JSONConfig/JSONConfigDefaults have some options to help support arbitrary precision arithmetic.
setPreciseNumbers(true) will cause numbers which would lose precision in 64-bit floating point to be surrounded by quotes in the generated JSON. This allows you to use the string with an arbitrary precision arithmetic package using full original precision.
setEncodeNumericStringsAsNumbers(true) when used with JSONParser will cause it to look at string values and to see if they look like either integer or floating point numbers. If they do, then it will parse them.
For all numbers, JSONParser will check to see if it can be encoded as 64-bit floating point or 64-bit long integer without losing precision. If it cannot, then it will be encoded as a BigDecimal or a BigInteger. You can decide whether or not to lose precision after that.