Thanks Daniel,
I see. So I need to use "=" for numerical comparisons. "equal?" is only true if 
the types are the same, too:
    (equal? 1.0 1)
    ; #f
    (= 1.0 1)
    ; #t

Sorry for filing a bug report. Feel free to close the bug.

Regards
Jan

On November 22, 2017 3:53:00 PM GMT, Daniel Llorens <daniel.llor...@bluewin.ch> 
wrote:
>
>> From: Jan Wedekind <j...@wedesoft.de>
>> Subject: bug#29387: Guile-2.2.2 complex numbers edge case
>> Date: 21 Nov 2017 23:09:57 GMT+1
>> To: 29...@debbugs.gnu.org
>> Reply-To: Jan Wedekind <j...@wedesoft.de>
>> 
>> 
>> Hi,
>> I think I encountered a bug in the numerical stack.
>> i times i should equal -1:
>> 
>>    (equal? -1 (* 0+i 0+i))
>>    ; #f
>> 
>> i times i plus one is zero (which is correct):
>>    (zero? (+ (* 0+i 0+i) 1))
>>    ; #t
>> 
>> Regards
>> Jan
>
>In Guile 0+i and (* 0+i 0+i) are inexact numbers, but -1 is exact.
>That's why equal? fails.
>
>You can check that either of
>
>(equal? -1.+0. (* 0+i 0+i))
>
>or
>
> (= -1 (* 0+i 0+i))
>
>return true, as expected.
>
>I don't know if the fact that Guile doesn't have exact complex numbers
>could be considered a bug. AFAIR none of the standards require them to
>be implemented. On the other hand I just checked and both Racket and
>Chez seem to have them, so...
>
>regards
>
>       Daniel

Reply via email to