numlib: fix return value of signum for complex zero

This commit is contained in:
Marius Gerbershagen 2019-08-19 20:26:10 +02:00
parent c1c68bb4fe
commit 2b3f7bb1fd

View file

@ -127,7 +127,9 @@ Returns zero for non-complex numbers."
Returns a number that represents the sign of NUMBER. Returns NUMBER If it is
zero. Otherwise, returns the value of (/ NUMBER (ABS NUMBER))"
(if (complexp x)
(cis (atan (imagpart x) (realpart x)))
(if (zerop x)
x
(cis (atan (imagpart x) (realpart x))))
(let ((result (cond ((> x 0) 1)
((< x 0) -1)
(t ; x is 0 or NaN