Long/Int in scala to hex string
val bigNum: Long = 13690566117625L
val bigHex: String = f"$bigNum%X"
Use %X
to get uppercase hex letters and %x
if you want lowercase.
You're looking for RichLong.toHexString
:
scala> 13690566117625L.toHexString
res0: String = c73955488f9
And the uppercase variant:
scala> 13690566117625L.toHexString.toUpperCase
res1: String = C73955488F9
Edit
This also available for Int
via RichInt.toHexString
:
scala> 42.toHexString
res4: String = 2a