Re: formatting rationals

On 2011-11-29 14:00:22 +0000, Frode V. Fjeld said:

BTW when I said that FORMAT is for human consumption, I should have said
"external consumption", as in anything external to CL itself. So you
might be writing 12499999/12500000 into some file format that only
accepts decimal notation, and for all you know the 0.00000002 difference
is extremely significant.

If I was writing it for consumption of something that dealt with rationals, then I'd print the rational (perhaps in a format whatever will read it understands, in the (rather unlikely) case it's not a/b. If I'm printing for something that expects floats, then that difference is not significant, because that difference *is* float rounding error. If I was printing for something that expects doubles, then I'd presumably have made the effort to coerce to a double.

So I guess there are a couple of remaining cases:
* printing for humans. As I said previously <huge string of digits><interesting couple of digits> is a seriously poor presentation for humans, and there are easy better alternatives.
* printing for something that supports big decimals or some other extended-precision float type. That's not a huge number of applications (and I bet they all deal with rationals as well).