IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
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).

IntLiteral

struct IntLiteral[value: __mlir_type.`!pop.int_literal`]

This type represents a static integer literal value with infinite precision. This type is a compile-time construct which stores its value as a parameter. It is typically materialized into other types (like Int) for use at runtime. This compile-time representation allows for arbitrary precision constants that would overflow on Int and other fixed precision integer types.

Parameters

  • value (__mlir_type.`!pop.int_literal`): The underlying integer value.

Implemented traits

AnyType, Boolable, Ceilable, Copyable, Defaultable, Floorable, ImplicitlyCopyable, ImplicitlyDestructible, Indexer, Intable, Movable, RegisterPassable, TrivialRegisterPassable, Truncable, Writable

Methods

__init__

def __init__() -> Self

Constructor for any value.

__bool__

def __bool__(self) -> Bool

Convert this IntLiteral to Bool.

Returns:

Bool: False Bool value if the value is equal to 0 and True otherwise.

__neg__

def __neg__(self) -> IntLiteral[(0 - value)]

Return -self.

Returns:

IntLiteral[(0 - value)]: The -self value.

__pos__

def __pos__(self) -> Self

Return +self.

Returns:

Self: The +self value.

__invert__

def __invert__(self) -> IntLiteral[(value ^ -1)]

Return ~self.

Returns:

IntLiteral[(value ^ -1)]: The ~self value.

__lt__

def __lt__(self, rhs: IntLiteral) -> Bool

Compare this IntLiteral to the RHS using LT comparison.

Args:

  • rhs (IntLiteral): The other IntLiteral to compare against.

Returns:

Bool: True if this IntLiteral is less-than the RHS IntLiteral and False otherwise.

__le__

def __le__(self, rhs: IntLiteral) -> Bool

Compare this IntLiteral to the RHS using LE comparison.

Args:

  • rhs (IntLiteral): The other IntLiteral to compare against.

Returns:

Bool: True if this IntLiteral is less-or-equal than the RHS IntLiteral and False otherwise.

__eq__

def __eq__(self, rhs: IntLiteral) -> Bool

Compare this IntLiteral to the RHS using EQ comparison.

Args:

  • rhs (IntLiteral): The other IntLiteral to compare against.

Returns:

Bool: True if this IntLiteral is equal to the RHS IntLiteral and False otherwise.

__ne__

def __ne__(self, rhs: IntLiteral) -> Bool

Compare this IntLiteral to the RHS using NE comparison.

Args:

  • rhs (IntLiteral): The other IntLiteral to compare against.

Returns:

Bool: True if this IntLiteral is non-equal to the RHS IntLiteral and False otherwise.

__gt__

def __gt__(self, rhs: IntLiteral) -> Bool

Compare this IntLiteral to the RHS using GT comparison.

Args:

  • rhs (IntLiteral): The other IntLiteral to compare against.

Returns:

Bool: True if this IntLiteral is greater-than the RHS IntLiteral and False otherwise.

__ge__

def __ge__(self, rhs: IntLiteral) -> Bool

Compare this IntLiteral to the RHS using GE comparison.

Args:

  • rhs (IntLiteral): The other IntLiteral to compare against.

Returns:

Bool: True if this IntLiteral is greater-or-equal than the RHS IntLiteral and False otherwise.

__add__

def __add__(self, rhs: IntLiteral) -> IntLiteral[(value + rhs.value)]

Return self + rhs.

Args:

Returns:

IntLiteral[(value + rhs.value)]: self + rhs value.

__sub__

def __sub__(self, rhs: IntLiteral) -> IntLiteral[(value - rhs.value)]

Return self - rhs.

Args:

Returns:

IntLiteral[(value - rhs.value)]: self - rhs value.

__mul__

def __mul__(self, rhs: IntLiteral) -> IntLiteral[(value * rhs.value)]

Return self * rhs.

Args:

  • rhs (IntLiteral): The value to multiply with.

Returns:

IntLiteral[(value * rhs.value)]: self * rhs value.

__floordiv__

def __floordiv__(self, rhs: IntLiteral) -> IntLiteral[(value // rhs.value)]

Return self // rhs.

Args:

Returns:

IntLiteral[(value // rhs.value)]: self // rhs value.

__mod__

def __mod__(self, rhs: IntLiteral) -> IntLiteral[(value % rhs.value)]

Return the remainder of self divided by rhs.

Args:

Returns:

IntLiteral[(value % rhs.value)]: The remainder of dividing self by rhs.

__pow__

def __pow__(self, exp: IntLiteral) -> IntLiteral[(value ** exp.value)]

Return the value raised to the power of the given exponent.

Args:

Returns:

IntLiteral[(value ** exp.value)]: The value of self raised to the power of exp.

__lshift__

def __lshift__(self, rhs: IntLiteral) -> IntLiteral[(value << rhs.value)]

Return self << rhs.

Args:

Returns:

IntLiteral[(value << rhs.value)]: self << rhs.

__rshift__

def __rshift__(self, rhs: IntLiteral) -> IntLiteral[(value >> rhs.value)]

Return self >> rhs.

Args:

Returns:

IntLiteral[(value >> rhs.value)]: self >> rhs.

__and__

def __and__(self, rhs: IntLiteral) -> IntLiteral[(value & rhs.value)]

Return self & rhs.

Args:

Returns:

IntLiteral[(value & rhs.value)]: self & rhs.

__or__

def __or__(self, rhs: IntLiteral) -> IntLiteral[(value | rhs.value)]

Return self | rhs.

Args:

Returns:

IntLiteral[(value | rhs.value)]: self | rhs.

__xor__

def __xor__(self, rhs: IntLiteral) -> IntLiteral[(value ^ rhs.value)]

Return self ^ rhs.

Args:

Returns:

IntLiteral[(value ^ rhs.value)]: self ^ rhs.

__int__

def __int__(self) -> Int

Convert from IntLiteral to Int.

Returns:

Int: The value as an integer of platform-specific width.

__ceil__

def __ceil__(self) -> Self

Return the ceiling of the IntLiteral value, which is itself.

Returns:

Self: The IntLiteral value itself.

__floor__

def __floor__(self) -> Self

Return the floor of the IntLiteral value, which is itself.

Returns:

Self: The IntLiteral value itself.

__trunc__

def __trunc__(self) -> Self

Return the truncated of the IntLiteral value, which is itself.

Returns:

Self: The IntLiteral value itself.

write_to

def write_to(self, mut writer: T)

Writes the IntLiteral in string form.

Args:

  • writer (T): The Writer to write the value to.

write_repr_to

def write_repr_to(self, mut writer: T)

Writes the IntLiteral in repr form.

Args:

  • writer (T): The Writer to write the value to.

__ceildiv__

def __ceildiv__(self, denominator: IntLiteral) -> IntLiteral[(0 - (value // (0 - denominator.value)))]

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

Args:

Returns:

IntLiteral[(0 - (value // (0 - denominator.value)))]: The ceiling of dividing numerator by denominator.