# Differences

This shows you the differences between two versions of the page.

 cl:functions:signum [2019/09/14 05:00] cl:functions:signum [2019/09/20 08:00] (current) Line 1: Line 1: + ====== Function SIGNUM ====== + + ====Syntax==== + * **signum** //number// → //​signed-prototype//​ + + ====Arguments and Values==== + * //number// - a //​[[CL:​Glossary:​number]]//​. + * //​signed-prototype//​ - a //​[[CL:​Glossary:​number]]//​. + + ====Description==== + **signum** determines a numerical value that indicates whether //number// is negative, zero, or positive. + + For a //​[[CL:​Glossary:​rational]]//,​ **signum** returns one of ''​-1'',​ ''​0'',​ or ''​1''​ according to whether //number// is negative, zero, or positive. For a //​[[CL:​Glossary:​float]]//,​ the result is a //​[[CL:​Glossary:​float]]//​ of the same format whose value is minus one, zero, or one. For a //​[[CL:​Glossary:​complex]]//​ number //z//, ''​(signum //​z//​)''​ is a complex number of the same phase but with unit magnitude, unless //z// is a complex zero, in which case the result is //z//. + + For //​[[CL:​Glossary:​rational]]//​ //​[[CL:​Glossary:​arguments]]//,​ **signum** is a rational function, but it may be irrational for //​[[CL:​Glossary:​complex]]//​ //​[[CL:​Glossary:​arguments]]//​. + + If //number// is a //​[[CL:​Glossary:​float]]//,​ the result is a //​[[CL:​Glossary:​float]]//​. If //number// is a //​[[CL:​Glossary:​rational]]//,​ the result is a //​[[CL:​Glossary:​rational]]//​. If //number// is a //​[[CL:​Glossary:​complex float]]//, the result is a //​[[CL:​Glossary:​complex float]]//. If //number// is a //​[[CL:​Glossary:​complex rational]]//,​ the result is a //​[[CL:​Glossary:​complex]]//,​ but it is //​[[CL:​Glossary:​implementation-dependent]]//​ whether that result is a //​[[CL:​Glossary:​complex rational]]//​ or a //​[[CL:​Glossary:​complex float]]//. + + ====Examples==== + <​blockquote> ​ + (signum 0) 0 + (signum 99) 1 + (signum 4/5) 1 + (signum -99/100) -1 + (signum 0.0) <​r>​0.0 + (signum #c(0 33)) <​r>#​C(0.0 1.0) + (signum #c(7.5 10.0)) <​r>#​C(0.6 0.8) + (signum #c(0.0 -14.7)) <​r>#​C(0.0 -1.0) + ([[CL:​Functions:​eql]] (signum -0.0) -0.0) <​r>//​[[CL:​Glossary:​true]]//​ + ​ + + ====Side Effects==== + None. + + ====Affected By==== + None. + + ====Exceptional Situations==== + None. + + ====See Also==== + * {\secref\FloatSubstitutability} + + ====Notes==== + <​blockquote> ​ + (signum x) ≡ ([[CL:​Special Operators:​if]] ([[CL:​Functions:​zerop]] x) x ([[CL:​Functions:​math-divide|/​]] x ([[CL:​Functions:​abs]] x))) + ​ +

### Page Tools 