3 ms·
Why does jq need arbitrary precision floating-point numbers?
by jwilk 9y ago
Why does jq need arbitrary precision floating-point numbers?
- cryptonector 9y agoThe most FAQ / most filed issue for jq may well be that IEEE754 sucks. Users are frequently surprised by IEEE754 issues.
- dnautics 9y agonot that it's needed, but JSONschema has this kind of crazy part where it lets you do multipleOf for floating point numbers. Of course 2.7 is not a multiple of 0.3 in IEEE-64-bit FP.
- geofft 9y agoBecause JSON's spec defines a "number" as an arbitrary-precision floating point number, no limit on how many digits can be before or after the decimal or on what positive or negative integers you can put after the "e". Despite the name "JavaScript Object Notation," it does not inherit JavaScript's traditional interpretation that a "number" is an IEEE 754 double. (JSON also does not permit infinities or NaN, which JavaScript does permit.) http://json.org/ http://json.org/
- deleted 9y ago[deleted]
- re 9y agoWouldn't jq be better served by a library supporting arbitrary precision decimal values? LibBF is for base-2 floating point.
- whyever 9y agoProbably yes, because you always want to convert to and from base 10 strings. mpdecimal [1] (which was developed for Python) might be a better choice, because it uses base 10 internally. [1] http://www.bytereef.org/mpdecimal/ http://www.bytereef.org/mpdecimal/