Skip to main content

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

@fieldwise_init
struct Foo(CeilDivableRaising, ImplicitlyCopyable):
    var x: Float64

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

Implemented traits

AnyType, ImplicitlyDestructible

comptime members

__del__is_trivial

comptime __del__is_trivial

A flag (often compiler generated) to indicate whether the implementation of __del__ is trivial.

The implementation of __del__ is considered to be trivial if:

  • The struct has a compiler-generated trivial destructor and all its fields have a trivial __del__ method.

In practice, it means that the __del__ can be considered as no-op.

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.

Raises:

If the operation fails.

Was this page helpful?