3 ms·
"Why don't we just" because it's harder than one thinks. https://en.m.wikipedia.org/wiki/Arbitrary-precision_arithmetic https://en.m.wikipedia.org/wiki/Arbitra
by gowld 7y ago
"Why don't we just" because it's harder than one thinks.
https://en.m.wikipedia.org/wiki/Arbitrary-precision_arithmetic https://en.m.wikipedia.org/wiki/Arbitrary-precision_arithmet...
and gets harder when you want exact irrationals too
https://www.google.com/search?q=exact+real+arithmetic https://www.google.com/search?q=exact+real+arithmetic
- amelius 7y agoAlso, it's a lot less efficient, so it should only be used if absolutely necessary.
- contravariant 7y agoAlthough this does make me wonder what happens if you round the rational once the numerator/denominator becomes too big. But maybe that just results in all the floating point weirdness again, just not for small rationals.
- jacobolus 7y agoThe result is that your number system (a) makes many common operations dramatically more computationally expensive, (b) has less predictable rounding which is very tricky to reason about, (c) generally gives worse results for the same bit budget. Instead of e.g. evenly spaced numbers, you get spacing like https://en.wikipedia.org/wiki/Minkowski%27s_question-mark_function https://en.wikipedia.org/wiki/Minkowski%27s_question-mark_fu... One thing you can try is storing a floating point numerator and a floating point denominator, and renormalizing them by bit shifts instead of finding GCDs. This lets you avoid rounding errors for small ratios. For general purposes this advantage isn’t really worth doubling the number of bits and complicating arithmetic for though. See e.g. https://observablehq.com/@jrus/qang https://observablehq.com/@jrus/qang