Skip to main content
Log in

Mojo module

math

Defines basic math functions for use in the open source parts of the standard library since the math package is currently closed source and cannot be depended on in the open source parts of the standard library.

These are Mojo built-ins, so you don't need to import them.

Traits

  • Absable: The Absable trait describes a type that defines an absolute value operation.
  • Powable: The Powable trait describes a type that defines a power operation (i.e. exponentiation) with the same base and exponent types.
  • Roundable: The Roundable trait describes a type that defines a rounding operation.

Functions

  • abs: Get the absolute value of the given object.
  • divmod: Performs integer division and returns the quotient and the remainder.
  • max: Gets the maximum of two integers.
  • min: Gets the minimum of two integers.
  • pow: Computes the base raised to the power of the exp.
  • round: Get the rounded value of the given object.