3 ms·
Yeah there are plenty of JS libraries for large numbers, but all of them are a bit of a hack. They are not as fast as native compiler/interpreter support, and t
by rpedela 13y ago
Yeah there are plenty of JS libraries for large numbers, but all of them are a bit of a hack. They are not as fast as native compiler/interpreter support, and there is no obvious way to integrate the logic into other native functions such as JSON.parse and JSON.stringify. So you have to create your own JSON parser which is not as fast like I did: https://github.com/datalanche/json-bignum https://github.com/datalanche/json-bignum
- Raphael 13y agoIf you want to use native JSON, store it as an object with a string. { "small": 2, "large": { "bignum": "-9223372036854775807.4237482374983253298159" } } Then make sure to replace or treat the object as a big number. Granted, it is more busywork.
- rpedela 13y agoThat is fine if the JSON consumer and producer are Javascript. What happens when the producer is a language that handles large numbers correctly? The numbers are rounded in Javascript.