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



Jaime,

For your application, wouldn't it be enough to set fpprintprec to 14 or 15?

In fact, perhaps that should be the default.  The naive user will get
results that are rounded correctly -- with more than enough digits for
practical purposes.

The sophisticated user can reset fpprintprec to false in order to have
numbers print in such a way that they can be read back in exactly.

            -s

On Wed, Nov 30, 2011 at 05:50, Jaime Villate <villate at fe.up.pt> wrote:

> On 11/30/2011 07:36 AM, Raymond Toy 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.
>>
>>
>>
> Hi,
> Something like that would be very useful to me. I use Maxima to
> generate several random versions of a quiz and sometimes I run
> across numbers such as 7.9e-5 which I have to turn into a string
> in order to display it like that; 79/100000 or 7.899999999999999e-5
> are not very convenient for the text of a quiz question.
> Perhaps there should be a flag to choose between the 123/10
> and 1.23r1 displays?
>
> Regards,
> Jaime
>
> ______________________________**_________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>;
>