# [Maxima] adding floats. a peculiarity, and a proposal

Raymond Toy raymond.toy
Fri Sep 1 07:46:47 CDT 2006

```>>>>> "Richard" == Richard Fateman <fateman at cs.berkeley.edu> writes:

Richard> in 5.9.3, xmaxima
Richard> (%i8) sum(0.1d0,i,1,1000);
Richard> (%o8) 			       99.99999999999859
Richard> (%i9) sum(0.1d0,i,1,1000000);
Richard> (%o9) 			       100000.0000013329

Richard> It's like that old joke "we lose a little on each sale, but we make it up on
Richard> the volume..."

Haha!

Richard> I have (yet another) proposal for floats for people to think
Richard> about, courtesy of W. Kahan..

Richard> In one sentence:

Richard>  ALL user floating-point format input be stored as infinitely precise
Richard> rational numbers until
Richard> there is a first conversion to something that is used computationally, at
Richard> which point it is
Richard> converted to the appropriate type, precision, etc.

So in the examples above, what would be the result? 100 and 1000000?
100d0 and 100000d0?

Not sure I like this.  If I said 0.1d0, then I want 0.1d0.  If I
wanted an exact rational I would have said 1/10.  However, it would be
useful to have, say, 0.1234567r0 mean the exact rational
1234567/100000000, without me having to write the denominator
explicitly.

Ray

```