문제

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?

도움이 되었습니까?

해결책

scala> BigInt("61d54e71b6c8409f9586ffd4cf9ffada",16)
res0: scala.math.BigInt = 130042665859304569025379016689359780570
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top