david CHOLLEZ
david CHOLLEZ

Reputation: 167

how to use a string representation of a Long to declare a Long variable?

I want to use the string representation of a Long to create a Long of this value

val strLong:String = "0xFF007A45"

And I want a Long with this value

val LongIWant:Long = 0xFF007A45

I tried toLong(), as Long and many other way, but none of them works

Is it possible ?

Regards

Upvotes: 0

Views: 165

Answers (1)

val strLong: String = "0xFF007A45"
val longYouWant: Long = strLong.substringAfter("0x").toLong(radix = 16)

Upvotes: 3

Related Questions