January 2018
Intermediate to advanced
434 pages
14h 1m
English
In the preceding examples, we were parsing strings with radix 10, that is, decimals. By default, the radix is taken as 10, but there are certain situations where we need different radix. For example, in case of parsing a string into a binary or octal number. So now, we will see how to work with radix other than the decimal. Though you can use any valid radix, we will show examples that are most commonly used, such as binary and octal.
fun main(args: Array<String>) { val str="11111111" print(str.toLongOrNull(2)) }
On running the preceding program, the following output is generated:
255
Read now
Unlock full access