mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-11 23:40:36 -07:00
numlib.lsp: make signum return proper values for infinity/NaN
This commit is contained in:
parent
2cbe875668
commit
d9a105dabc
1 changed files with 9 additions and 1 deletions
|
|
@ -126,7 +126,15 @@ Returns zero for non-complex numbers."
|
|||
"Args: (number)
|
||||
Returns a number that represents the sign of NUMBER. Returns NUMBER If it is
|
||||
zero. Otherwise, returns the value of (/ NUMBER (ABS NUMBER))"
|
||||
(if (zerop x) x (/ x (abs x))))
|
||||
(if (complexp x)
|
||||
(cis (atan (imagpart x) (realpart x)))
|
||||
(let ((result (cond ((> x 0) 1)
|
||||
((< x 0) -1)
|
||||
(t ; x is 0 or NaN
|
||||
x))))
|
||||
(if (floatp x)
|
||||
(float result x)
|
||||
result))))
|
||||
|
||||
(defun cis (x)
|
||||
"Args: (radians)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue