class Int
src
class Int is Cool does Real { ... }
Int objects store integral numbers of arbitrary size. Int s are immutable.
There are two main syntax forms for Int literals
123 # Int in decimal notation
:16<BEEF> # Int in radix notations
Both forms allow underscores between any two digits which can serve as visual
separators, but don't carry any meaning:
5_00000 # five Lakhs
500_000 # five hundred thousand
Methods
chr
multi sub chr(Int:D ) returns Str:D
multi method chr(Int:D:) returns Str:D
Returns a one-character string, by interpreting the integer as a Unicode
codepoint number and converting it the corresponding character.
Operators
div
multi sub infix:<div>(Int:D, Int:D) returns Int:D
Does an integer division, rounded down.
expmod
multi sub expmod (Int:D: Int $y, Int $mod) returns Int:D
multi method expmod (Int:D: Int $y, Int $mod) returns Int:D
Returns the given Int raised to the $y power within modulus $mod .
is-prime
multi sub is-prime (Int:D: Int $tries = 100) returns Bool:D
multi method is-prime (Int:D: Int $tries = 100) returns Bool:D
Returns True if this Int is known to be a prime, or is likely to be a
prime based on a probabalistic Miller-Rabin test. $tries is the maximal
number of iterations the test is allowed to do.
Returns False if this Int is known not to be a prime.