@@ -25,38 +25,68 @@ generally return L<Num> in Perl 6.
25
25
26
26
= head2 method Real
27
27
28
+ Defined as:
29
+
28
30
method Real(Numeric:D:) returns Real:D
29
31
32
+ Usage:
33
+
34
+ NUMERIC.Real
35
+
30
36
If this C < Numeric > is equivalent to a C < Real > , return that C < Real > .
31
37
Fail with C < X::Numeric::Real > otherwise.
32
38
33
39
= head2 method Int
34
40
41
+ Defined as:
42
+
35
43
method Int(Numeric:D:) returns Int:D
36
44
45
+ Usage:
46
+
47
+ NUMERIC.Int
48
+
37
49
If this C < Numeric > is equivalent to a C < Real > , return the equivalent of
38
50
calling C < truncate > on that C < Real > to get an C < Int > . Fail with
39
51
C < X::Numeric::Real > otherwise.
40
52
41
53
= head2 method Rat
42
54
55
+ Defined as:
56
+
43
57
method Rat(Numeric:D: Real $epsilon = 1.0e-6) returns Rat:D
44
58
59
+ Usage:
60
+
61
+ NUMERIC.Rat
62
+
45
63
If this C < Numeric > is equivalent to a C < Real > , return a C < Rat > which is
46
64
within C < $epsilon > of that C < Real > 's value. Fail with C < X::Numeric::Real >
47
65
otherwise.
48
66
49
67
= head2 method Num
50
68
69
+ Defined as:
70
+
51
71
method Num(Numeric:D:) returns Num:D
52
72
73
+ Usage:
74
+
75
+ NUMERIC.Num
76
+
53
77
If this C < Numeric > is equivalent to a C < Real > , return that C < Real > as a C < Num >
54
78
as accurately as is possible. Fail with C < X::Numeric::Real > otherwise.
55
79
56
80
= head2 method narrow
57
81
82
+ Defined as:
83
+
58
84
method narrow(Numeric:D) returns Numeric:D
59
85
86
+ Usage:
87
+
88
+ NUMERIC.narrow
89
+
60
90
Returns the number converted to the narrowest type that can hold it without
61
91
loss of precision.
62
92
@@ -65,51 +95,98 @@ loss of precision.
65
95
66
96
= head2 method ACCEPTS
67
97
98
+ Defined as:
99
+
68
100
multi method ACCEPTS(Numeric:D: $other)
69
101
102
+ Usage:
103
+
104
+ NUMERIC.ACCEPTS(OTHER)
105
+
70
106
Returns True if C < $other > is numerically the same as the invocant.
71
107
72
108
= head2 routine log
73
109
110
+ Defined as:
111
+
74
112
multi sub log(Numeric:D, Numeric $base = e) returns Numeric:D
75
113
multi method log(Numeric:D: Numeric $base = e) returns Numeric:D
76
114
115
+ Usage:
116
+
117
+ log NUMERIC, NUMERIC?
118
+ NUMERIC.log(NUMERIC?)
119
+
77
120
Calculates the logarithm to base C < $base > . Defaults to the natural logarithm.
78
121
79
122
= head2 routine log10
80
123
124
+ Defined as:
125
+
81
126
multi sub log10(Numeric:D ) returns Numeric:D
82
127
multi method log10(Numeric:D:) returns Numeric:D
83
128
129
+ Usage:
130
+
131
+ log10 NUMERIC
132
+ NUMERIC.log10
133
+
84
134
Calculates the logarithm to base 10.
85
135
86
136
= head2 routine exp
87
137
138
+ Defined as:
139
+
88
140
multi sub exp(Numeric:D, Numeric:D $base = e) returns Numeric:D
89
141
multi method exp(Numeric:D: Numeric:D $base = e) returns Numeric:D
90
142
143
+ Usage:
144
+
145
+ exp NUMERIC, NUMERIC?
146
+ NUMERIC.exp(NUMERIC?)
147
+
91
148
Returns C < $base > to the power of the number, or C < e > to the power of the
92
149
number if called without a second argument.
93
150
94
151
= head2 method roots
95
152
153
+ Defined as:
154
+
96
155
multi method roots(Numeric:D: Int:D $n) returns Positional
97
156
157
+ Usage:
158
+
159
+ NUMERIC.roots(INTEGER)
160
+
98
161
Returns a list of the C < $n > complex roots, which evaluate to the original
99
162
number when raised to the C < $n > th power.
100
163
101
164
= head2 routine abs
102
165
166
+ Defined as:
167
+
103
168
multi sub abs(Numeric:D ) returns Real:D
104
169
multi method abs(Numeric:D:) returns Real:D
105
170
171
+ Usage:
172
+
173
+ abs NUMERIC
174
+ NUMERIC.abs
175
+
106
176
Returns the absolute value of the number.
107
177
108
178
= head2 routine sqrt
109
179
180
+ Defined as:
181
+
110
182
multi sub sqrt(Numeric:D) returns Numeric:D
111
183
multi method sqrt(Numeric:D) returns Numeric:D
112
184
185
+ Usage:
186
+
187
+ sqrt NUMERIC
188
+ NUMERIC.sqrt
189
+
113
190
Returns a square root of the number. For real numbers the positive square
114
191
root is returned.
115
192
@@ -120,27 +197,51 @@ use the C<roots> method.
120
197
121
198
= head2 method conj
122
199
200
+ Defined as:
201
+
123
202
multi method conj(Numeric:D) returns Numeric:D
124
203
204
+ Usage:
205
+
206
+ NUMERIC.conj
207
+
125
208
Returns the complex conjugate of the number. Returns the number itself for
126
209
real numbers.
127
210
128
211
= head2 method Bool
129
212
213
+ Defined as:
214
+
130
215
multi method Bool(Numeric:D:)
131
216
217
+ Usage:
218
+
219
+ NUMERIC.Bool
220
+
132
221
Returns C < False > if the number is equivalent to zero, and C < True > otherwise.
133
222
134
223
= head2 method succ
135
224
225
+ Defined as:
226
+
136
227
method succ(Numeric:D:)
137
228
229
+ Usage:
230
+
231
+ NUMERIC.succ
232
+
138
233
Returns the number incremented by one (successor).
139
234
140
235
= head2 method pred
141
236
237
+ Defined as:
238
+
142
239
method pred(Numeric:D:)
143
240
241
+ Usage:
242
+
243
+ NUMERIC.pred
244
+
144
245
Returns the number decremented by one (predecessor).
145
246
146
247
= end pod
0 commit comments