3 ms·
I feel like at some point the performance hit of using actual rationals (pairs of bignums) makes sense
by afiori 3y ago
I feel like at some point the performance hit of using actual rationals (pairs of bignums) makes sense
- adgjlsfhk1 3y agoThe downside of rationals is that they degrade extremely quickly as soon as you take a sqrt or do trig. Decimal floating point has the advantage of losing accuracy in the places people are used to.
- afiori 3y agoI believe that for almost all rationals trig functions never return a rational so you must have some kind of rounding tecnique. An advantage of rationals is that you have much more freedom in handling how the rounding works, for example you can limit your rounding to produce fractions n/2^m and then they behave sort of like floats or n/10^m and then they behave like decimals while still being able to know that basic arithmetic operations (+, *, -, /, <, <=, <>, mod, exponentiation by integer) work as precisely as you want them to. GPUs, ML, an massive numericall processing will want to always use floats, ints, posits[0] with operations that can be efficiently implemented in hardware but most apps could easily afford to use bigint/bigint rationals for most things. [0] https://spectrum.ieee.org/floating-point-numbers-posits-processor https://spectrum.ieee.org/floating-point-numbers-posits-proc...