rational numbers only



you can try  rat(0.5 + 1/3 - 3/8 +0.3*1/4)
but this is not a good idea in general.  Some decimal numbers will not
come out exactly right because they are, internally, converted to binary
floating point numbers. There is no exact binary floating point number
for certain decimal numbers, like 0.1

If you want to do exact decimal arithmetic and conversion to rational
numbers, you need to convert numbers like .12345   to 12345/10^5, exactly.

RJF


----- Original Message ----- 
From: "Jorge Barros de Abreu" <ficmatin01 at solar.com.br>
To: "Richard Fateman" <fateman at cs.berkeley.edu>; "Stavros Macrakis" 
<macrakis at gmail.com>
Cc: <Maxima at math.utexas.edu>
Sent: Wednesday, January 04, 2006 10:53 AM
Subject: Re: [Maxima] rational numbers only


> Hi Richard and Stravos.
>
> My original idea was avoid manual convertion like 0.5 to 1/2. But as this 
> is
> not automatically make for maxima the original idea was changed:
>
> Need a function that view an generic numerical expression of any lenght 
> like:
>
> 0.5 + 1/3 - 3/8 +0.3*1/4
>
> detect the decimal number, convert it for rational number, show the 
> convertion
> of this decimal to rational and show the result in a rational number.
>
> This is for teaching childrens to calculate the num?rical expressions and
> return its value in a simplificated form.
>
> Thanks.
>
> Em Wed 04 Jan 2006 14:58, Richard Fateman escreveu:
>> Don't put any floating point numbers into maxima.  Use 1/2   not 0.5
>>
>> Or you can use the program  rat(......)
>> to convert to rational approximations, in some contexts.
>
> -- 
> Data Estelar 2453738.308414
> http://www.solar.com.br/~ficmatin
> Desejo-lhe Paz, Vida Longa e Prosperidade.
> S?o Bem Vindas Mensagens no Formato Texto Gen?rico com Acentos.
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>