I'm getting a message from a server which has an intel dual core processor and Windows. The message is supposed to be a bunch of binary single-precision floating point numbers. The size of the numbers appear to be the same as the Java float, but the format does not seem to be the same.
I used some code from a website ( that almost works (i.e. the numbers are relatively close to correct, but still unacceptably off):
I have also tried to write some of my own code, but haven't been too successful not knowing much about binary conversions and number formats. Can anyone help me with this? Have I provided enough information about the machine?
-Bones
I used some code from a website ( that almost works (i.e. the numbers are relatively close to correct, but still unacceptably off):
Code:
float readFloatLittleEndian()
{
int accum = 0;
for ( int shiftBy=0; shiftBy<32; shiftBy+=8 )
{
accum |= ( readByte () & 0xff ) << shiftBy;
}
return Float.intBitsToFloat( accum );
}
I have also tried to write some of my own code, but haven't been too successful not knowing much about binary conversions and number formats. Can anyone help me with this? Have I provided enough information about the machine?
-Bones