With Integer.toString(1234567, 16).toUpperCase() // output: 12D68
could help to convert an Int
to Hex string.
How to do the same with Long?
Long.toString(13690566117625, 16).toUpperCase() // but this will report error
You're looking for RichLong.toHexString
:
scala> 13690566117625L.toHexString
res0: String = c73955488f9
And the uppercase variant:
scala> 13690566117625L.toHexString.toUpperCase
res1: String = C73955488F9
This also available for Int
via RichInt.toHexString
:
scala> 42.toHexString
res4: String = 2a
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