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).

Arguments:

number [number! money! time!]

See also:

abs   negate  

Description

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

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

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
-2000
size: 20
num: -30
if size > 10 [xy: 10x20 * sign? num]
print xy
-10x-20


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin