Mojo struct
FloatLiteral
@register_passable(trivial)
struct FloatLiteral
Mojo floating point literal type.
Aliases
fp_type = !kgen.float_literal
:nan = #kgen.float_literal<nan>
:infinity = #kgen.float_literal<inf>
:negative_infinity = #kgen.float_literal<neg_inf>
:negative_zero = #kgen.float_literal<neg_zero>
:
Fields
- value (
!kgen.float_literal
): The underlying storage for the floating point value.
Implemented traits
Absable
,
AnyType
,
Boolable
,
CeilDivable
,
Ceilable
,
CollectionElement
,
Comparable
,
Copyable
,
EqualityComparable
,
Floatable
,
Floorable
,
ImplicitlyBoolable
,
Intable
,
Movable
,
Roundable
,
Stringable
,
Truncable
,
UnknownDestructibility
Methods
__init__
@implicit
__init__(out self, value: !kgen.float_literal)
Create a FloatLiteral value from a kgen.float_literal value.
Args:
- value (
!kgen.float_literal
): The float value.
@implicit
__init__(out self, value: IntLiteral)
Convert an IntLiteral to a FloatLiteral value.
Args:
- value (
IntLiteral
): The IntLiteral value.
__bool__
__bool__(self) -> Bool
A FloatLiteral value is true if it is non-zero.
Returns:
True if non-zero.
__neg__
__neg__(self) -> Self
Return the negation of the FloatLiteral value.
Returns:
The negated FloatLiteral value.
__lt__
__lt__(self, rhs: Self) -> Bool
Less than comparison.
Args:
- rhs (
Self
): The value to compare.
Returns:
True if this value is less than rhs
.
__le__
__le__(self, rhs: Self) -> Bool
Less than or equal to comparison.
Args:
- rhs (
Self
): The value to compare.
Returns:
True if this value is less than or equal to rhs
.
__eq__
__eq__(self, rhs: Self) -> Bool
Compare for equality.
Args:
- rhs (
Self
): The value to compare.
Returns:
True if they are equal.
__ne__
__ne__(self, rhs: Self) -> Bool
Compare for inequality.
Args:
- rhs (
Self
): The value to compare.
Returns:
True if they are not equal.
__gt__
__gt__(self, rhs: Self) -> Bool
Greater than comparison.
Args:
- rhs (
Self
): The value to compare.
Returns:
True if this value is greater than rhs
.
__ge__
__ge__(self, rhs: Self) -> Bool
Greater than or equal to comparison.
Args:
- rhs (
Self
): The value to compare.
Returns:
True if this value is greater than or equal to rhs
.
__add__
__add__(self, rhs: Self) -> Self
Add two FloatLiterals.
Args:
- rhs (
Self
): The value to add.
Returns:
The sum of the two values.
__sub__
__sub__(self, rhs: Self) -> Self
Subtract two FloatLiterals.
Args:
- rhs (
Self
): The value to subtract.
Returns:
The difference of the two values.
__mul__
__mul__(self, rhs: Self) -> Self
Multiply two FloatLiterals.
Args:
- rhs (
Self
): The value to multiply.
Returns:
The product of the two values.
__truediv__
__truediv__(self, rhs: Self) -> Self
Divide two FloatLiterals.
Args:
- rhs (
Self
): The value to divide.
Returns:
The quotient of the two values.
__floordiv__
__floordiv__(self, rhs: Self) -> Self
Returns self divided by rhs, rounded down to the nearest integer.
Args: