File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,23 @@ Examples:
168
168
169
169
TODO
170
170
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
+
171
188
= head2 routine split
172
189
173
190
= for code :skip-test
You can’t perform that action at this time.
0 commit comments