Skip to main content
Log in

Mojo function

divmod

divmod(numerator: Int, denominator: Int) -> Tuple[Int, Int]

Performs integer division and returns the quotient and the remainder.

Currently supported only for integers. Support for more standard library types like Int8, Int16... is planned.

This method calls a.__divmod__(b), thus, the actual implementation of divmod should go in the __divmod__ method of the struct of a.

Args:

  • numerator (Int): The dividend.
  • denominator (Int): The divisor.

Returns:

A Tuple containing the quotient and the remainder.

divmod(numerator: UInt, denominator: UInt) -> Tuple[UInt, UInt]

Performs integer division and returns the quotient and the remainder.

Currently supported only for integers. Support for more standard library types like Int8, Int16... is planned.

This method calls a.__divmod__(b), thus, the actual implementation of divmod should go in the __divmod__ method of the struct of a.

Args:

  • numerator (UInt): The dividend.
  • denominator (UInt): The divisor.

Returns:

A Tuple containing the quotient and the remainder.

Was this page helpful?