Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting 3 bytes to a float

807588Jun 4 2009 — edited Jun 4 2009
I need to decode a small byte array containing of size 3 from a binary file. I used the InputStream's read() method to get each byte (which returns an int after each read) and casted them back into byte to put them in a byte array.

I need to represent these 3 bytes as ONE number.

I know that the number is supposed to be -125.000 however, when I use System.out.println(byte[index]) on the three bytes, I get -127, -27, and 72 respectively (printing from byte[0] to byte[2]).

Any ideas on how to convert these bytes into the correct number?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 2 2009
Added on Jun 4 2009
3 comments
1,004 views