converting byte array to float
Can somebody please supply me with some code to convert a 4-byte array into
a float? In C, you can just cast a float pointer to the byte pointer, but
no such mechanism exists in Java.
Re: converting byte array to float
DataInputStream dis = new DataInputStream(new
float f = dis.readFloat();
However, if you originally read the 4 bytes from a file or some other input
stream, why not go back and change your program to read the float number
directly from that source? Wrap your input stream in a DataInputStream as
in the code above.
"Curtis Nelson" <curtis_nelson@@larsondavis.com> wrote in message
> Can somebody please supply me with some code to convert a 4-byte array
> a float? In C, you can just cast a float pointer to the byte pointer, but
> no such mechanism exists in Java.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center