I am writing an applet where I have data in byte array. I receive data of type word (2 bytes) , double word( 4 bytes), real (4 bytes). I want to display these on the screen. I can display word and double word as integer values. But I am unable to display real(could be a float) type data. Example :
I receive 32.71 as a byte array 0x42, 0x02, 0xD7, 0x0A and -32.71 as 0xC2, 0x02, 0xD7, 0x0A
Can anybody help me with java code for the above problem? So that I can interpret the array of bytes data as float/double and display it on screen.?
For Word and DWord to be displayed as integer values, I convert the bytes to a Hex String and using
Integer.parseInt(String, radix)
I am getting the integer values. Is something similar not possible for converting float values? Is there any other way I can interpret these integer and float values? Please help!
From what I remember, can't a float be a very big number with lots of values after the decimal point? If it is then I might be able to suggest something.
The numbers that I will be receiving would be in the IEEE 754 floating point format and 4 bytes each. That would limit the range according to float MAX values.