Mojo trait
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 math import CeilDivable
@value
struct Foo(CeilDivable):
var x: Float64
fn __ceildiv__(self, denominator: Self) -> Self:
return Self(self.x // denominator.x)
from math import CeilDivable
@value
struct Foo(CeilDivable):
var x: Float64
fn __ceildiv__(self, denominator: Self) -> 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.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!