Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > decoding a binary format, can not convert float data correctly

Reply
Thread Tools

decoding a binary format, can not convert float data correctly

 
 
Hongbo Liu
Guest
Posts: n/a
 
      05-07-2011
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.
 
Reply With Quote
 
 
 
 
Heikki Kallasjoki
Guest
Posts: n/a
 
      05-08-2011
On 2011-05-07, Hongbo Liu <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Barry Schwarz
Guest
Posts: n/a
 
      05-08-2011
On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
<(E-Mail Removed)> 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
 
Reply With Quote
 
Hongbo Liu
Guest
Posts: n/a
 
      05-08-2011
On May 8, 1:26*am, Barry Schwarz <(E-Mail Removed)> wrote:
> On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
>
>
>
>
>
>
>
>
>
> <(E-Mail Removed)> 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,
 
Reply With Quote
 
Hongbo Liu
Guest
Posts: n/a
 
      05-08-2011
On May 8, 5:46*pm, Hongbo Liu <(E-Mail Removed)> wrote:
> On May 8, 1:26*am, Barry Schwarz <(E-Mail Removed)> wrote:
>
>
>
>
>
>
>
>
>
> > On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu

>
> > <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
need code to convert float format to internal java float format which is kept in 4 bytes integer Andy Java 7 05-10-2004 09:26 PM
float (*Data)[4] vs float *Data[4] Kutty Banerjee C Programming 5 03-04-2004 11:11 AM
how to convert 16-bit binary fraction to a float music4 C Programming 4 09-20-2003 02:59 AM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments