routine parse-base

Documentation for routine parse-base assembled from the following types:

class Str

From Str

(Str) routine parse-base

multi sub    parse-base(Str:D $numInt:D $radix --> Numeric)
multi method parse-base(Str:D $num: Int:D $radix --> Numeric)

Performs the reverse of base by converting a string with a base-$radix number to its Numeric equivalent. Will fail if radix is not in range 2..36 or if the string being parsed contains characters that are not valid for the specified base.

1337.base(32).parse-base(32).say# OUTPUT: «1337␤» 
'Perl6'.parse-base(30).say;       # OUTPUT: «20652936␤» 
'FF.DD'.parse-base(16).say;       # OUTPUT: «255.863281␤»

See also: :16<FF> syntax for number literals