parse-base
ErrorsCollection

parse-base

Synthesised documentation from type/Str

From type/Str

See Original text in context

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 Fails 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␤» 
'Raku'.parse-base(36).say;        # OUTPUT: «1273422␤» 
'FF.DD'.parse-base(16).say;       # OUTPUT: «255.863281␤»

See also: syntax for number literals