Skip to content

Commit 9fc1402

Browse files
committed
Add Real.{Int,Num,Rat} coercers ref #3782
... and remove non-existent Numeric.{Int,Num,Real} ones
1 parent 31bad39 commit 9fc1402

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

doc/Type/Numeric.pod6

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,6 @@ Defined as:
3535
The C<:D> variant simply returns the invocant. The C<:U> variant issues a warning about using
3636
an uninitialized value in numeric context and then returns C<self.new>.
3737
38-
=head2 method Int
39-
40-
method Int(Numeric:D: --> Int:D)
41-
42-
If this C<Numeric> is equivalent to a C<Real>, return the equivalent of
43-
calling C<truncate> on that C<Real> to get an C<Int>. Fail with
44-
C<X::Numeric::Real> otherwise.
45-
46-
=head2 method Rat
47-
48-
method Rat(Numeric:D: Real $epsilon = 1.0e-6 --> Rat:D)
49-
50-
If this C<Numeric> is equivalent to a C<Real>, return a C<Rat> which is
51-
within C<$epsilon> of that C<Real>'s value. Fail with C<X::Numeric::Real>
52-
otherwise.
53-
54-
=head2 method Num
55-
56-
method Num(Numeric:D: --> Num:D)
57-
58-
If this C<Numeric> is equivalent to a C<Real>, return that C<Real> as a C<Num>
59-
as accurately as is possible. Fail with C<X::Numeric::Real> otherwise.
60-
6138
=head2 method narrow
6239
6340
method narrow(Numeric:D --> Numeric:D)

doc/Type/Real.pod6

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,20 @@ it is an L<Int|/type/Int> when we instantiated C<Temperature> with an L<Int|/typ
6868
Converts the number to a C<Complex> with the number converted to a C<Num> as
6969
its real part and 0e0 as the imaginary part.
7070
71+
=head2 method Int
72+
73+
method Int(Real:D:)
74+
75+
Calls the L«C<Bridge> method|/routine/Bridge» on the invocant and then
76+
calls the L«C<Int> method|/routine/Int» on its return value.
77+
7178
=head2 method Rat
7279
7380
method Rat(Real:D: Real $epsilon = 1e-6)
7481
75-
Converts the number to a C<Rat> with the precision C<$epsilon>.
82+
Calls the L«C<Bridge> method|/routine/Bridge» on the invocant and then
83+
calls the L«C<Rat> method|/routine/Rat» on its return value with the
84+
C<$epsilon> argument.
7685
7786
=head2 method Real
7887
@@ -85,6 +94,13 @@ The C<:D> variant simply returns the invocant. The C<:U> variant issues a
8594
warning about using an uninitialized value in numeric context and then returns
8695
C<self.new>.
8796
97+
=head2 method Num
98+
99+
method Num(Real:D:)
100+
101+
Calls the L«C<Bridge> method|/routine/Bridge» on the invocant and then
102+
calls the L«C<Num> method|/routine/Num» on its return value.
103+
88104
=head2 routine rand
89105
90106
sub term:<rand> (--> Num:D)

0 commit comments

Comments
 (0)