For Programmers: Free Programming Magazines  


Home > Archive > Scheme > September 2004 > Re: R5RS numbers









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: R5RS numbers
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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com