0

sign

To return the signum of a number

You can use the function to determine the sign of a number. The return value is either 1 (positive number) or -1 (negative number). The number 0 is considered positive.

Syntax

sign(number)

Return

number

Examples

sign(x) To return the signum of number x.

sign(10 + 12)

Result: 1

 

sign(10 - 13)

Result: -1

 

sign(0)

Result: 1

 

sign(10.2)

Result: 1

See also

even, which returns Yes (true) if the number is even.

odd, which returns Yes (true) if the number is odd.

Reply

null