Skip to main content

Mojo function

signum

signum(a: Int) -> Int

Calculate the sign of an integer.

This function determines the sign of the input integer and returns a corresponding indicator value.

Example:

from layout.int_tuple import signum

var result1 = signum(5)    # Returns 1
var result2 = signum(-10)  # Returns -1
var result3 = signum(0)    # Returns 0

.

Args:

  • a (Int): The integer value to determine the sign of.

Returns:

Int: 1 if a > 0, -1 if a < 0, 0 if a == 0.

Was this page helpful?