exact decimal type, was: 12.3*70.95 a little bit weird
Subject: exact decimal type, was: 12.3*70.95 a little bit weird
From: Raymond Toy
Date: Wed, 30 Nov 2011 09:49:05 -0800
On Wed, Nov 30, 2011 at 9:21 AM, Stavros Macrakis <macrakis at alum.mit.edu>wrote:
> How about rat(12.345678)? Of course, ratepsilon should be 2e-15 or so
> (which we agreed on in February 2005, but it's still 1e-8!) and you
> probably want to turn off ratprint.
The most recent code has ratepsilon set to 2e-15. Finally. :-)
>
> I really think the 999r9 notation is *extremely* special-purpose and not
> worth adding.
>
Using rat is probably better than r, and generalizes better.
>
> As for fpprintprec, the only reason I know to print all digits is to
> ensure that print/read is reversible. Which is important, but shouldn't
> interfere with ordinary use which doesn't need it. What other reasons are
> there?
>
Well, it's a goal of the printer and I'm pretty sure there's really one one
possible answer. If you no longer print out all the digits, you now get to
deal with how the printer decides to round the result. The CLHS
explicitly says it's not specified, so different implementations could now
print out different results for exactly the same (simple) arithmetic
operation.
Another reason is the if you don't print out all the bits, naive users will
wonder why comparing two numbers returns false, even though they look equal
because not all the bits were printed. (I find it easy to forget what
fpprintprec is set to, especially if it's close to 15.)
Ray