[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

decoding a binary format, can not convert float data correctly

Hongbo Liu

5/7/2011 9:09:00 PM

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.
6 Answers

Datesfat Chicks

5/7/2011 10:18:00 PM

0

On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
<liuhongbo@sysdynecorp.com> wrote:

>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.

Based on the data you provided, really nothing makes sense. I can't
decipher it.

Can you control the values and then get the binary representations?

As a starting point, I would try powers of two, 2^q, letting q range
from -16 to +16.

Then I would try powers of 10.

And see if any patterns emerge.

I can't make heads or tails of it.

DFC

Heikki Kallasjoki

5/8/2011 12:16:00 AM

0

On 2011-05-07, Hongbo Liu <liuhongbo@sysdynecorp.com> wrote:
> 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...

--
Heikki Kallasjoki
email: echo 'zfs+es_t_i@n_u.zf' | tr zen_muftis fuze_mints

Barry Schwarz

5/8/2011 5:26:00 AM

0

On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
<liuhongbo@sysdynecorp.com> wrote:

>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.

--
Remove del for email

Datesfat Chicks

5/8/2011 6:30:00 PM

0

On 08 May 2011 00:16:20 GMT, Heikki Kallasjoki
<see@end.of.message.invalid> wrote:
>On 2011-05-07, Hongbo Liu <liuhongbo@sysdynecorp.com> wrote:
>> 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...

Heikki: I have to compliment you on your deductive abilities.

To the OP: I'd be interested in hearing more about the history of
this system and the format.

Using 59 as the basis for fixed-point representation is something I've
never seen before.

Using a power of 2 as the basis is very common, so that the radix
point occurs between two bits.

Using a power of 10 is also very common; for example representing
money as integer cents or hundredths of cents or something like that.

But 59?

The only observation I'd make about 59 is that it is prime, which
doesn't seem to be relevant to whether it is a good basis for a fixed
point representation.

DFC

Hongbo Liu

5/8/2011 9:47:00 PM

0

On May 8, 1:26 am, Barry Schwarz <schwa...@dqel.com> wrote:
> On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
>
>
>
>
>
>
>
>
>
> <liuhon...@sysdynecorp.com> wrote:
> >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.
>
> --
> Remove del for email

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

Thanks,

Hongbo Liu

5/8/2011 10:02:00 PM

0

On May 8, 5:46 pm, Hongbo Liu <liuhon...@sysdynecorp.com> wrote:
> On May 8, 1:26 am, Barry Schwarz <schwa...@dqel.com> wrote:
>
>
>
>
>
>
>
>
>
> > On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
>
> > <liuhon...@sysdynecorp.com> wrote:
> > >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.
>
> > --
> > Remove del for email
>
> 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.