| Ray Dillinger 2004-09-22, 3:59 am |
| Marcin 'Qrczak' Kowalczyk wrote:
>
> 5854679515581645/4503599627370496
Whoa, hold the phone. This is a reasonably close approximation
but I got two questions -- where's the second argument to
inexact->exact, and why is this an approximation? Shouldn't it
just be 13/10? You're supposed to get the simplest rational
that's within range of the number, and 13/10 is within range
(I guarantee, even with the range argument missing) and way
simpler than 5854679515581645/4503599627370496.
[color=darkred]
> 1
[color=darkred]
> 1+0.0i
This is a slightly odd result. It's clearly an inexact number,
but why isn't it written back by the interpreter as 1.0+0.0i ?
[color=darkred]
> (2.0 2)
This however, is a clear error. You can't take the real part
of an inexact complex number and get an exact real number.
>
> #t
>
> The last case is silly, because the numbers are not equivalent.
Yes, they absolutely are; they are inexact complex numbers having
the same value. Your implementation here is doing exactly the
right thing, both mathematically and to the letter and spirit of
R5RS.
Bear
|