Skip to main content
Log in

Mojo function

abs

abs[T: Absable](value: T) -> $0

Get the absolute value of the given object.

Parameters:

  • ​T (Absable): The type conforming to Absable.

Args:

  • ​value (T): The object to get the absolute value of.

Returns:

The absolute value of the object.

abs(value: IntLiteral) -> IntLiteral

Get the absolute value of the given IntLiteral.

Args:

  • ​value (IntLiteral): The IntLiteral to get the absolute value of.

Returns:

The absolute value of the IntLiteral.

abs(value: FloatLiteral) -> FloatLiteral

Get the absolute value of the given FloatLiteral.

Args:

  • ​value (FloatLiteral): The FloatLiteral to get the absolute value of.

Returns:

The absolute value of the FloatLiteral.

Was this page helpful?