3.5.2.1.63 Sign

Description

The sign(x) function returns the sign of real number x. It returns 1 if x > 0 and returns -1 if x < 0; For x = 0, zero is returned.

Syntax

int sign(double x)

Parameter

x

can be any real number.

Return

Returns the sign of real number x.

Example

sign(5) = ; //should return 1
sign(-5) = ; //should return -1