3 ms·
You obviously can't have the entire rationals, because your computer's memory is finite. And if you are approximating anyway, adding space to the mantissa of bo
by marcosdumay 5y ago
You obviously can't have the entire rationals, because your computer's memory is finite. And if you are approximating anyway, adding space to the mantissa of both the numerator and denominator will approximate values about as well as adding space only into one of them (the actual gain grows with O(log(n)) of those sizes).
Thus, if you won't work with exact numbers, the best choice to represent rationals is to place all bits you can at the mantissa of a single side, and just store the order of magnitude of the other side. And, for simplicity you want the mantissa on the numerator side. What is basically a floating point number.
Things are very different if you will work with exact numbers.
- alisonkisk 5y ago> You obviously can't have the entire rationals, because your computer's memory is finite. This doesn't matter, because our programs and data are finite. Bignum (which is plain old Integer in Haskell) is unbounded, but commonm
- marcosdumay 5y agoThe memory size does not matter. For any finite size, you will get a closer approximation of the rationals from floating point than by a ratio of integers. The difference ratio only gets bigger when you add more memory.