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



This seems to add complexity where in fact simplicity is needed.

The naive user who is confused by the trailing digits in 12.3*70.95 is
hardly likely to write 12.3r0*70.95r0.  And the sophisticated user
shouldn't find it too hard to write 123*10^-1 (3 extra keystrokes), and has
a variety of ways of controlling the form of the output.

Then there's the complication of output.  Do users who enter the fraction
2/5 really want to see 4.0r-1 on output?  I doubt it.  But users who enter
0.4r1 presumably don't want to see 2/5, either.  So then do we need to keep
track of the *origin* of each rat?  Do we want 2/5*3 to print as 6/5, but
2/5*3r0 to print as 1.2r0?  Yuck yuck yuck.

This seems like a lot of complexity for a very simple problem.  The vast
majority of cases are, I suspect, handled satisfactorily by simply making
fpprintprec:14 by default.

           -s

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

> On 11/29/11 11:17 PM, Robert Dodier wrote:
> > Dan, as others have pointed out, the discrepancy you observed
> > stems from floating point numbers being only approximations
> > to decimal numbers.
> >
> > I wonder if it would be worth the trouble to invent an exact
> > decimal type for Maxima. One can already get exact arithmetic
> > by using fractions, e.g. 123/10 instead of 12.3 or 95/100 instead
> > of 0.95, but that's kind of clumsy. How about something like,
> > I don't know, 12.3x0 to denote a number exactly equal to 123/10 ?
> > Any interest in that?
> >
> We had discussed this some time ago.  I had proposed 12.3r0, with "r"
> for rational.  One issue was that you would enter 12.3r0, but maxima
> would print 123/10.  It would be nice if maxima could output 12.3r0
> instead.  I guess we could hack the printer to check for rationals and
> if the denominator only contained factors of 2 or 5, then something
> special could be done.  On the other hand, a user might prefer 123/10.
>
> Ray
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>