IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

signum

def 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?