There is a string of numbers HexUtils.byteArrayToHexString(explicitXBeeMessage.getData()).substring(0,8) checked the string, the number is output correctly from 0 to FFFFFFFF range, the number can be converted to the 10th floating point system. Options Double.parseDouble() and others - work only on small numbers a la 0x0005
|
2 answers
The maximum number in your range - FFFFFFFF is equal in decimal system 4294967295 , it will not fit into Integer in Java, but will fit into Long . In fact, this is the maximum unsigned 4-byte integer. Since Java does not know how to unsigned, you need to use Long .
The following code will be able to parse any value from your range from the variable hex , then you can simply write it in double if necessary:
String hex = "FFFFFFFF"; System.out.println(Long.parseLong(hex, 16)); 4294967295
- Thanks, helped
(double)Long.parseLong(HexUtils.byteArrayToHexString(explicitXBeeMessage.getData()).substring(0,8),16)- Klaus
|
And before the heap can
String hex = "FFFFFFFF"; long l = Long.valueOf(hex, 16); BigInteger b = new BigInteger(hex, 16); |