I need to convert from Binary String to Int or Long in Kotlin. Is there any inbuilt utility method available for the same?
that's how you can do;
println("11001".toInt(2))
println("11001".toLong(2))
As Joffrey said in the comment, "the 2 here is the number's base. That's why it's 2 for binary, would be 16 for hexadecimal"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With