Question

I have a number, in this case it is 61d54e71b6c8409f9586ffd4cf9ffada.

I would like to work with it's numeric representation.

In python I would do:

 number = 61d54e71b6c8409f9586ffd4cf9ffada

But I am using Scala, not python.

I have tried:

scala> val bd = BigDecimal("61d54e71b6c8409f9586ffd4cf9ffada")
java.lang.NumberFormatException

And:

scala> val bd = BigDecimal("0x61d54e71b6c8409f9586ffd4cf9ffada")
java.lang.NumberFormatException

If the number were smaller, I could just do:

scala> val bd = 0x61d54e
bd: Int = 6411598

Anyone got any suggestions?

Était-ce utile?

La solution

scala> BigInt("61d54e71b6c8409f9586ffd4cf9ffada",16)
res0: scala.math.BigInt = 130042665859304569025379016689359780570
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top