Hello Everyone,
I am trying to convert 4 Bytes (in Hexadecimal form) into decimal. However, I'd like to store this number into an Integer. Is this possible?
In Java, it says that an Integer's Maximum value is 2,147,483,647 (Roughly, 2 Billion). The Integer's Minimum value is - 2,147,483,648.
For Hexadecimals, 4 Bytes would have a maximum value of FFFF FFFF, which in decimal is 4,294,967,295 (Roughly 4 Billion).
I've noticed that an Integer can actually carry the same amount of capacity, meaning from the range of (-2,147,483,648 to 2,147,483,647) - it is equivalent to 4,294,967,295. So, from this... it seems that it can hold the same capacity. However, I'd like to be able to store the number 4,294,967,295 into an integer variable. This seems like it is not possible and that I will have to revert to using a type Long. Does anyone know a work around for this or have any suggestions on what I should do? So far, here's a piece of my code that is sort of what I'm trying to do.
int i = Integer.valueOf("FFFFFFFF", 16); // Number Format Exception - This is the problem.System.out.println("FFFF FFFF = " + i); // I want to be able to encapsulate the value of FFFF FFFF inside of an integer. int maxInt = Integer.MAX_VALUE;System.out.println("Max Integer: " + maxInt); int minInt = Integer.MIN_VALUE;System.out.println("Min Integer: " + minInt);
It seems like Java cares about signed values when it comes to bits.
Thanks in advance,
Brian