Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (33 sloc) 1.45 KB
=begin pod
=TITLE class Int
class Int is Cool does Real { ... }
C<Int> objects store integral numbers of arbitrary size. C<Int>s are immutable.
There are two main syntax forms for C<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
=head1 Methods
=head2 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.
=head1 Operators
=head2 div
multi sub infix:<div>(Int:D, Int:D) returns Int:D
Does an integer division, rounded down.
=head2 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 C<Int> raised to the C<$y> power within modulus C<$mod>.
=head2 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 C<True> if this C<Int> is known to be a prime, or is likely to be a
prime based on a probabalistic Miller-Rabin test. C<$tries> is the maximal
number of iterations the test is allowed to do.
Returns C<False> if this C<Int> is known not to be a prime.
=end pod
Something went wrong with that request. Please try again.