Skip to content

Commit d82788a

Browse files
committed
document $digits argument to .base
stolen from the design docs
1 parent 8ba60b3 commit d82788a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/Type/Real.pod

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,21 @@ Rounds the number towards zero.
5959
6060
=head2 method base
6161
62-
method base(Real:D: Int:D $base where 2..36) returns Str:D
62+
method base(Real:D: Int:D $base where 2..36, $digits?) returns Str:D
6363
6464
Converts the number to a string, using C<$base> as base. For C<$base> larger
6565
than ten, capital Latin letters are used.
6666
67-
255.base(16) # 'FF'
67+
255.base(16) # 'FF'
68+
69+
The optional C<$digits> argument asks for that many digits of fraction
70+
(which may not be negative). If omitted, a reasonable default is chosen
71+
based on type. For Int this default is 0. For L<Num|/type/Num>, the default is 8.
72+
For L<Rational|/type/Rational>, the number of places is scaled to the size of the denominator,
73+
with a minimum of 6.
74+
75+
The final digit produced is always rounded.
76+
77+
say pi.base(10, 5); # 3.14159
6878
6979
=end pod

0 commit comments

Comments
 (0)