Skip to content

Commit 4b9944d

Browse files
authored
Document parse-base()
Added to Rakudo in rakudo/rakudo@b1cbb8b
1 parent 06707c8 commit 4b9944d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/Type/Str.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,23 @@ Examples:
168168
169169
TODO
170170
171+
=head2 routine parse-base
172+
173+
multi sub parse-base(Str:D $num, Int:D $radix) returns Numeric
174+
multi method parse-base(Str:D $num: Int:D $radix) returns Numeric
175+
176+
Performs the reverse of L«C<Numeric>|/routine/base» by converts a string
177+
with a base-C<$radix> number to its base-10 L«C<Numeric>|/type/Numeric»
178+
equivalent. Will L«C<fail>|/routine/fail» if radix is not in range C<2..36>
179+
or of the string being parsed contains characters that are not valid
180+
for the specified base.
181+
182+
1337.base(32).parse-base(32).say; # 1337
183+
'Perl6'.parse-base(30).say; # 20652936
184+
'FF.DD'.parse-base(16).say; # 255.863281
185+
186+
See also: L«:16<FF> syntax for number literals|/syntax/Number%20literals»
187+
171188
=head2 routine split
172189
173190
=for code :skip-test

0 commit comments

Comments
 (0)