REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: sign?

sign?  number

Returns sign of number as 1, 0, or -1 (to use as multiplier).


number [number! money! time!]

See also:

abs   negate  


The SIGN? function returns a positive, zero, or negative integer based on the sign of its argument.

print sign? 1000
print sign? 0
print sign? -1000

The sign is returned as an integer to allow it to be used as a multiplication term within an expression:

val: -5
new: 2000 * sign? val
print new
size: 20
num: -30
if size > 10 [xy: 10x20 * sign? num]
print xy

  TOC < Back Next > - WIP Wiki Feedback Admin