exact decimal type, was: 12.3*70.95 a little bit weird



It's a pity that the CLHS is underspecified here.  But I suspect that this
only matters in very rare cases, namely when the binary representation is *
exactly* equal to a decimal number with 5000... after the last digit.  So
we'd have cases like

    print(2342342342342345.0),fpprintprec:14;

which might print as

    2.34234234234235E+15
or
    2.34234234234234E+15

on different implementations.

I really find it hard to believe that *any *user, especially a naive user,
will ever notice that numbers like this print differently in the last digit
in some implementations.  They are more likely to be confused
when 10000000000000005.0 prints out as 1.0000000000000004E+16 (because ...5
is not representable).

As for naive users wondering why comparing two floats returns false even
though they look equal, yes, I suppose that will be a FAQ, just like why
sqrt(2.0)^2-2 isn't equal to 0.  Anyway, we already seem to have the "look
equal" problem.  On Maxima 5.25.1 GCL 2.6.8, sqrt(2.0)^2 prints as 2.0, but
sqrt(2.0)^2-2 => 4.4e-16.

           -s

On Wed, Nov 30, 2011 at 12:49, Raymond Toy <toy.raymond at gmail.com> wrote:

> 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
>
>