On 12/23/2013 07:44 PM, Mikael wrote:I don't think so. inexact->exact works on numbers, the #e notation
> Dear Marc or Brad,
>
> First - Happy Holidays! :))
>
> A Q:
>
> > #e0.3
> 3/10
> > (inexact->exact 0.3)
> 5404319552844595/18014398509481984
>
>
> > #e0.2
> 1/5
> > (inexact->exact 0.2)
> 3602879701896397/18014398509481984
>
>
> Why the different results? Is there any way to get the #e behavior in
> a more effective way than (string-append "#e" (number->string n))?
works on strings. The reader turns "0.3" by default into
5404319552844595/18014398509481984, the closest floating-point 64-bit
binary number to 0.3.
I did exactly the trick of appending "#e" to the front of numerical
strings for a homework-on-the-web system that I wrote when the students
expected to use exact decimal arithmetic.
See:
> (- .3 3/10)
0.
> (= .3 3/10)
#f
Brad
_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list