decoding a binary format, can not convert float data correctly

H

Hongbo Liu

Recently, I am trying to decoding a binary data file. However, can not
decode the float data correctly.
For example:

1.0 is 3B000000
3.5 is CF000000
16.0 is B0030000
10.0 is 4E020000

I tried the ieee standard and microsoft binary foramt standard , both
are not working.

I knew the result (1.0, 3.5,16.0) because I got the print out paper
from the customer. But, I don't know which language the original
program used. The program runs on DOS system.

Any help would be appreciated.
Thanks in advance.
 
H

Heikki Kallasjoki

Recently, I am trying to decoding a binary data file. However, can not
decode the float data correctly.
For example:

1.0 is 3B000000
3.5 is CF000000
16.0 is B0030000
10.0 is 4E020000

Not that this is related to C or topical in this group, but...

Based on the above, that looks like a little-endian fixed-pointish
format, not a floating-point one:

3B000000 -> 0x3b = 59 -> 59/59 = 1.0
CF000000 -> 0xcf = 207 -> 207/59 = 3.50847...
B0030000 -> 0x3b0 = 944 -> 944/59 = 16.0
4E020000 -> 0x24e = 590 -> 590/59 = 10.0

Admittedly a fixed-point format where the divisor is 59 (and not some
sensible power of 2) is rather arbitrary, but, well...
 
B

Barry Schwarz

Recently, I am trying to decoding a binary data file. However, can not
decode the float data correctly.
For example:

1.0 is 3B000000
3.5 is CF000000
16.0 is B0030000
10.0 is 4E020000

I tried the ieee standard and microsoft binary foramt standard , both
are not working.

I knew the result (1.0, 3.5,16.0) because I got the print out paper
from the customer. But, I don't know which language the original
program used. The program runs on DOS system.

Maybe you would like to tell us on what system the data was produced.
It would also help to know if the data is stored in a float or a
double.

For what it is worth, your hex does not match my system using an Intel
6600 with Microsoft Visual C.
 
H

Hongbo Liu

Maybe you would like to tell us on what system the data was produced.
It would also help to know if the data is stored in a float or a
double.

For what it is worth, your hex does not match my system using an Intel
6600 with Microsoft Visual C.

The system is running MS DOS. It is for sure only 4 bytes for each
number. can we say it should be float?

Thanks,
 
H

Hongbo Liu

The system is running MS DOS. It is for sure only 4 bytes for each
number. can we say it should be float?

Thanks,

Sorry for everybody who is trying to help me out here. I made a
mistake. The number is stored as integer. But when the software print
it out, it actually is divided by another integer before it print out,
so show decimal number on the paper.

Heikki Kallasjoki 's found out the factor of 59 really remind me
something, then i knew i made a mistake.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top