Mojo trait
IntLike
The IntLike
trait is a tag for Int
or UInt
. This allows writing functions that works on either.
Implemented traits
Absable
,
AnyType
,
Ceilable
,
Floorable
,
Powable
,
Stringable
,
Truncable
,
Writable
Methods
__pow__
__pow__(self: T, exp: T) -> T
Return the value raised to the power of the given exponent.
Args:
- exp (
T
): The exponent value.
Returns:
The value of self
raised to the power of exp
.
__mlir_index__
__mlir_index__(self: T) -> index
Convert to index.
Returns:
The corresponding __mlir_type.index value.
__abs__
__abs__(self: T) -> T
Get the absolute value of this instance.
Returns:
The absolute value of the instance.
__ceil__
__ceil__(self: T) -> T
Return the ceiling of the Int value, which is itself.
Returns:
The Int value itself.
__floor__
__floor__(self: T) -> T
Return the floor of the Int value, which is itself.
Returns:
The Int value itself.
write_to
write_to[W: Writer](self: T, inout writer: W)
Formats the string representation of this type to the provided Writer.
Parameters:
- W (
Writer
): A type conforming to the Writable trait.
Args:
- writer (
W
): The type conforming toWritable
.
__str__
__str__(self: T) -> String
Get the string representation of the type.
Returns:
The string representation of the type.
__trunc__
__trunc__(self: T) -> T
Return the truncated Int value, which is itself.
Returns:
The Int value itself.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!