how do i assign a long hex value to the type data in java?

A long has a maximum of 64-bits, your number has way more than 64 bits.

To convert it to a BigInteger use: BigInteger(String val, int radix) where radix is 16 (for hex).

BigInteger(String val, int radix)
Translates the String representation of a BigInteger in the specified radix into a BigInteger.


BigInteger bi = new BigInteger("5C6847CA179309189D68679F8A77C3192577A242D5FF053F72F0E1A3F754191B8B0819BD367711F8195A4DA5FDE8F7EBFB12606DB3A1685DD92AF2126836D20F",16);

String value = "5C6847CA179309189D68679F8A77C3192577A242D5FF053F72F0E1A3F754191B8B0819BD367711F8195A4DA5FDE8F7EBFB12606DB3A1685DD92AF2126836D20F";
System.out.println((bi.toString(16)));
System.out.println(value.toLowerCase().compareTo(bi.toString(16)));
System.out.println(value.compareTo(bi.toString(16).toUpperCase()));

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top