2 sgn - indicator of sign of a real or complex number
10 return -1, 0, 1 (real)
11 -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i or 1-1i (complex)
14 Return the value of cmp(a,0).
16 For real x, sgn(x) returns:
21 For complex, sgn(x) returns:
23 sgn(re(x)) + sgn(im(x))*1i
27 ; print sgn(27), sgn(1e-20), sgn(0), sgn(-45)
30 ; print sgn(2+3i), sgn(6i), sgn(-7+4i), sgn(-6), sgn(-6-3i), sgn(-2i)
31 1+1i 1i -1+1i -1 -1-1i -1i
37 NUMBER *qsign(NUMBER *x)
42 ## Copyright (C) 1999 Landon Curt Noll
44 ## Calc is open software; you can redistribute it and/or modify it under
45 ## the terms of the version 2.1 of the GNU Lesser General Public License
46 ## as published by the Free Software Foundation.
48 ## Calc is distributed in the hope that it will be useful, but WITHOUT
49 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
50 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
51 ## Public License for more details.
53 ## A copy of version 2.1 of the GNU Lesser General Public License is
54 ## distributed with calc under the filename COPYING-LGPL. You should have
55 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
56 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
58 ## @(#) $Revision: 30.2 $
59 ## @(#) $Id: sgn,v 30.2 2008/05/10 13:23:57 chongo Exp $
60 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sgn,v $
62 ## Under source code control: 1995/10/25 04:03:46
63 ## File existed as early as: 1995
65 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
66 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/