0

Ok I have this hex string "efe4b4f355de4cbc" which I want to convert to integer. In python I do this:

print int("efe4b4f355de4cbc",16)

and the output I get is 17286140226965490876.

Now when I try to do the same in Java using the following code:

long convertedHex = Long.parseLong("efe4b4f355de4cbc", 16);

All I get is

java.lang.NumberFormatException: Invalid long: "efe4b4f355de4cbc"

But why?

Anyhow then I though I should try a BigInteger so next thing I did was this

long convertedHex = new BigInteger("efe4b4f355de4cbc", 16).longValue();

Now the result I get is -1160603846744060740 but that's not what I want. I want the same result as in python language.

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
ThanosFisherman
  • 5,626
  • 12
  • 38
  • 63

0 Answers0