For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
CeilDivable
The CeilDivable trait describes a type that defines a ceil division operation.
Types that conform to CeilDivable will work with the math.ceildiv
function.
For example:
from std.math import CeilDivable
@fieldwise_init
struct Foo(CeilDivable, ImplicitlyCopyable):
var x: Float64
def __ceildiv__(self, denominator: Self) -> Self:
return Self(self.x // denominator.x)
Implemented traits
Required methods
__ceildiv__
__ceildiv__(self: _Self, denominator: _Self) -> _Self
Return the rounded-up result of dividing self by denominator.
Args:
- denominator (
_Self): The denominator.
Returns:
_Self: The ceiling of dividing numerator by denominator.