On Thu, Mar 6, 2014, at 7:46, Stephen J. Turnbull wrote:
Steven D'Aprano writes:
The problem is that fractions can be unbounded in memory,
Seminumerical Algorithms has a few problems on "floating slash", ie a representation of numbers where the total memory allocated to a fraction is fixed, but the amounts allocated to numerator and denominator are variable. I don't know if it has ever been tried in practice, though. And of course any reasonable fixed size would have very limited ability to express very large or very small magnitudes.
Or, for that matter, you could limit both the numerator and the denominator to some maximum value - when an intermediate result exceeds it (won't be more than the square of the maximum for most operations), you find the closest representable value.