becks becks - 1 month ago 19
Java Question

How to convert BigDecimal to hex string?

I have a number of type BigDecimal and I want to convert it to hexadecimal value.

example value = 18446744073709551616

is there a way to do this instead of doing it manually ?



Judging by your example you should rather use BigInteger then BigDecimal. Try maybe this way

new BigInteger("18446744073709551616").toString(16)

or if you cant change type of your object convert it to BigInteger before

new BigDecimal("18446744073709551616").toBigInteger().toString(16);