-a // negation
a + b // addition
a - b // subtraction
a * b // multiplication
a / b // division
a ~/ b // integer division
a % b // remainder
a ** b // exponentiation
Comparison Operators
a == b // equality
a != b // inequality
a < b // less than
a > b // greater than
a <= b // less than or equal
a >= b // greater than or equal
Number vs. Float
To allow transparent use of Float and Int,
use Number instead of Float in type annotations.
Rounds this number to the next mathematical integer towards Infinity.
If this is an Int, returns this.
If this is NaN, Infinity, -Infinity, 0.0, or -0.0, returns this.
Otherwise, returns the smallest Float that is greater than or equal to this
and is equal to a mathematical integer.
Rounds this number to the next mathematical integer towards -Infinity.
If this is an Int, returns this.
If this is NaN, Infinity, -Infinity, 0.0, or -0.0, returns this.
Otherwise, returns the largest Float that is less than or equal to this
and is equal to a mathematical integer.
Rounds this number to the nearest mathematical integer, breaking ties in favor
of the even integer.
If this is an Int, returns this.
If this is NaN, Infinity, -Infinity, 0.0, or -0.0, returns this.
Otherwise, return the Float that is nearest to this and is equal to a
mathematical integer. If two mathematical integers are equally near, returns
the even integer.
Rounds this number to the next mathematical integer towards zero.
If this is an Int, returns this.
If this is NaN, Infinity, -Infinity, 0.0, or -0.0, returns this.
If this is less than zero, returns the smallest Float that is greater than or equal to this
and is equal to a mathematical integer.
Otherwise, returns the largest Float that is less than or equal to this
and is equal to a mathematical integer.
If this is an Int, returns this.
If this is NaN, Infinity, or -Infinity, throws an error.
Otherwise, returns the Int representation for this.truncate().
If this.truncate() is not representable in (that is, too large for) Int, throws an error.
If this is a Float, returns this.
Otherwise, returns the Float representation for this.
If this is not representable in Float, returns the Float nearest to this.
Common base class of
Int
andFloat
.