Skip to content

Math Signum

The math::signum function returns the sign of a number: -1 if the number is negative, 0 if it is zero, and 1 if it is positive.

Syntax

math::signum(<number>)

Parameters

  • number: The input number whose sign is to be determined.

Returns

  • Number: -1, 0, or 1 indicating the sign of the input number.

Example

Try it out below!
math::signum(-42)

This function is useful for determining the polarity of a number in mathematical or logical operations.