Skip to content

Commit 38ad1cc

Browse files
committed
Added usage statements to Numeric.pod
1 parent 8971386 commit 38ad1cc

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

doc/Type/Numeric.pod

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,38 +25,68 @@ generally return L<Num> in Perl 6.
2525
2626
=head2 method Real
2727
28+
Defined as:
29+
2830
method Real(Numeric:D:) returns Real:D
2931
32+
Usage:
33+
34+
NUMERIC.Real
35+
3036
If this C<Numeric> is equivalent to a C<Real>, return that C<Real>.
3137
Fail with C<X::Numeric::Real> otherwise.
3238
3339
=head2 method Int
3440
41+
Defined as:
42+
3543
method Int(Numeric:D:) returns Int:D
3644
45+
Usage:
46+
47+
NUMERIC.Int
48+
3749
If this C<Numeric> is equivalent to a C<Real>, return the equivalent of
3850
calling C<truncate> on that C<Real> to get an C<Int>. Fail with
3951
C<X::Numeric::Real> otherwise.
4052
4153
=head2 method Rat
4254
55+
Defined as:
56+
4357
method Rat(Numeric:D: Real $epsilon = 1.0e-6) returns Rat:D
4458
59+
Usage:
60+
61+
NUMERIC.Rat
62+
4563
If this C<Numeric> is equivalent to a C<Real>, return a C<Rat> which is
4664
within C<$epsilon> of that C<Real>'s value. Fail with C<X::Numeric::Real>
4765
otherwise.
4866
4967
=head2 method Num
5068
69+
Defined as:
70+
5171
method Num(Numeric:D:) returns Num:D
5272
73+
Usage:
74+
75+
NUMERIC.Num
76+
5377
If this C<Numeric> is equivalent to a C<Real>, return that C<Real> as a C<Num>
5478
as accurately as is possible. Fail with C<X::Numeric::Real> otherwise.
5579
5680
=head2 method narrow
5781
82+
Defined as:
83+
5884
method narrow(Numeric:D) returns Numeric:D
5985
86+
Usage:
87+
88+
NUMERIC.narrow
89+
6090
Returns the number converted to the narrowest type that can hold it without
6191
loss of precision.
6292
@@ -65,51 +95,98 @@ loss of precision.
6595
6696
=head2 method ACCEPTS
6797
98+
Defined as:
99+
68100
multi method ACCEPTS(Numeric:D: $other)
69101
102+
Usage:
103+
104+
NUMERIC.ACCEPTS(OTHER)
105+
70106
Returns True if C<$other> is numerically the same as the invocant.
71107
72108
=head2 routine log
73109
110+
Defined as:
111+
74112
multi sub log(Numeric:D, Numeric $base = e) returns Numeric:D
75113
multi method log(Numeric:D: Numeric $base = e) returns Numeric:D
76114
115+
Usage:
116+
117+
log NUMERIC, NUMERIC?
118+
NUMERIC.log(NUMERIC?)
119+
77120
Calculates the logarithm to base C<$base>. Defaults to the natural logarithm.
78121
79122
=head2 routine log10
80123
124+
Defined as:
125+
81126
multi sub log10(Numeric:D ) returns Numeric:D
82127
multi method log10(Numeric:D:) returns Numeric:D
83128
129+
Usage:
130+
131+
log10 NUMERIC
132+
NUMERIC.log10
133+
84134
Calculates the logarithm to base 10.
85135
86136
=head2 routine exp
87137
138+
Defined as:
139+
88140
multi sub exp(Numeric:D, Numeric:D $base = e) returns Numeric:D
89141
multi method exp(Numeric:D: Numeric:D $base = e) returns Numeric:D
90142
143+
Usage:
144+
145+
exp NUMERIC, NUMERIC?
146+
NUMERIC.exp(NUMERIC?)
147+
91148
Returns C<$base> to the power of the number, or C<e> to the power of the
92149
number if called without a second argument.
93150
94151
=head2 method roots
95152
153+
Defined as:
154+
96155
multi method roots(Numeric:D: Int:D $n) returns Positional
97156
157+
Usage:
158+
159+
NUMERIC.roots(INTEGER)
160+
98161
Returns a list of the C<$n> complex roots, which evaluate to the original
99162
number when raised to the C<$n>th power.
100163
101164
=head2 routine abs
102165
166+
Defined as:
167+
103168
multi sub abs(Numeric:D ) returns Real:D
104169
multi method abs(Numeric:D:) returns Real:D
105170
171+
Usage:
172+
173+
abs NUMERIC
174+
NUMERIC.abs
175+
106176
Returns the absolute value of the number.
107177
108178
=head2 routine sqrt
109179
180+
Defined as:
181+
110182
multi sub sqrt(Numeric:D) returns Numeric:D
111183
multi method sqrt(Numeric:D) returns Numeric:D
112184
185+
Usage:
186+
187+
sqrt NUMERIC
188+
NUMERIC.sqrt
189+
113190
Returns a square root of the number. For real numbers the positive square
114191
root is returned.
115192
@@ -120,27 +197,51 @@ use the C<roots> method.
120197
121198
=head2 method conj
122199
200+
Defined as:
201+
123202
multi method conj(Numeric:D) returns Numeric:D
124203
204+
Usage:
205+
206+
NUMERIC.conj
207+
125208
Returns the complex conjugate of the number. Returns the number itself for
126209
real numbers.
127210
128211
=head2 method Bool
129212
213+
Defined as:
214+
130215
multi method Bool(Numeric:D:)
131216
217+
Usage:
218+
219+
NUMERIC.Bool
220+
132221
Returns C<False> if the number is equivalent to zero, and C<True> otherwise.
133222
134223
=head2 method succ
135224
225+
Defined as:
226+
136227
method succ(Numeric:D:)
137228
229+
Usage:
230+
231+
NUMERIC.succ
232+
138233
Returns the number incremented by one (successor).
139234
140235
=head2 method pred
141236
237+
Defined as:
238+
142239
method pred(Numeric:D:)
143240
241+
Usage:
242+
243+
NUMERIC.pred
244+
144245
Returns the number decremented by one (predecessor).
145246
146247
=end pod

0 commit comments

Comments
 (0)