Skip to main content
Log in

Mojo trait

CeilDivableRaising

The CeilDivable trait describes a type that define a floor division and negation operation that can raise.

Types that conform to CeilDivableRaising will work with the // operator as well as the math.ceildiv function.

For example:

from math import CeilDivableRaising

@value
struct Foo(CeilDivableRaising):
var x: object

fn __ceildiv__(self, denominator: Self) raises -> Self:
return Self(self.x // denominator.x)
from math import CeilDivableRaising

@value
struct Foo(CeilDivableRaising):
var x: object

fn __ceildiv__(self, denominator: Self) raises -> Self:
return Self(self.x // denominator.x)

Implemented traits

AnyType, UnknownDestructibility

Methods

__ceildiv__

__ceildiv__(self: _Self, denominator: _Self) -> _Self

Return the rounded-up result of dividing self by denominator.

Args:

  • denominator (_Self): The denominator.

Returns:

The ceiling of dividing numerator by denominator.