Mojo function
signum
signum(a: Int) -> Int
Returns the sign of an integer value.
This helper function determines whether a number is positive, negative, or zero, returning 1 for positive, -1 for negative, and 0 for zero.
Args:
- a (
Int
): The integer value to determine the sign of.
Returns:
1 if a > 0, -1 if a < 0, 0 if a == 0.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!