[Maxima] rational numbers only
Stavros Macrakis
macrakis at alum.mit.edu
Wed Jan 4 12:33:02 CST 2006
------=_Part_257_30509762.1136399582032
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
>
> 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=E9rical expressions a=
nd
> return its value in a simplificated form.
>
If you set simp:false, then all simplifications will be turned off. You ca=
n
write any code you want to operate on the resulting expression.
If, on the other hand, you care about the difference between 0.5 =3D 5/10 a=
nd
0.50 =3D 50/100, you will have to parse the input yourself. If you don't
parse the input yourself, but convert the floats, you need to be careful
about comparisons in your float-to-rational conversion. For example,
0.29*100-29 is not 0.
-s
------=_Part_257_30509762.1136399582032
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
<div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(=
204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Need a funct=
ion that view an generic numerical expression of any lenght like:<br><br>0.=
5
+ 1/3 - 3/8 +0.3*1/4<br><br>detect the decimal number, convert it for rati=
onal number, show the convertion<br>of this decimal to rational and show th=
e result in a rational number.<br><br>This is for teaching childrens to cal=
culate the num=E9rical expressions and
<br>return its value in a simplificated form.<br></blockquote></div><br>If =
you set simp:false, then all simplifications will be turned off. You =
can write any code you want to operate on the resulting expression.<br><br>=
If, on the other hand, you care about the difference between=20
0.5 =3D 5/10 and 0.50 =3D 50/100, you will have to parse the input yourself=
. If you don't parse the input yourself, but convert the floats, you =
need to be careful about comparisons in your float-to-rational conversion.&=
nbsp; For example,=20
0.29*100-29 is not 0.<br><br> &nbs=
p; -s<br><br>
------=_Part_257_30509762.1136399582032--
More information about the Maxima
mailing list