/
Int.pod
56 lines (33 loc) 路 1.45 KB
/
Int.pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
=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