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: Jaime Villate
Date: Wed, 30 Nov 2011 10:50:33 +0000
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