From 2b3f7bb1fdb92ffd474cc189bfd0f37322d22197 Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Mon, 19 Aug 2019 20:26:10 +0200 Subject: [PATCH] numlib: fix return value of signum for complex zero --- src/lsp/numlib.lsp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lsp/numlib.lsp b/src/lsp/numlib.lsp index 32ba1d1fd..131c9692c 100644 --- a/src/lsp/numlib.lsp +++ b/src/lsp/numlib.lsp @@ -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