decoding a binary format, can not convert float data correctly

Discussion in 'C Programming' started by Hongbo Liu, May 7, 2011.

  1. Hongbo Liu

    Hongbo Liu Guest

    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.
     
    Hongbo Liu, May 7, 2011
    #1
    1. Advertising

  2. On 2011-05-07, Hongbo Liu <> 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
     
    Heikki Kallasjoki, May 8, 2011
    #2
    1. Advertising

  3. On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
    <> 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
     
    Barry Schwarz, May 8, 2011
    #3
  4. Hongbo Liu

    Hongbo Liu Guest

    On May 8, 1:26 am, Barry Schwarz <> wrote:
    > On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > <> 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, May 8, 2011
    #4
  5. Hongbo Liu

    Hongbo Liu Guest

    On May 8, 5:46 pm, Hongbo Liu <> wrote:
    > On May 8, 1:26 am, Barry Schwarz <> wrote:
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > > On Sat, 7 May 2011 14:09:02 -0700 (PDT), Hongbo Liu

    >
    > > <> 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.
     
    Hongbo Liu, May 8, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy
    Replies:
    7
    Views:
    6,291
    Roedy Green
    May 10, 2004
  2. bd
    Replies:
    0
    Views:
    651
  3. Kutty Banerjee

    float (*Data)[4] vs float *Data[4]

    Kutty Banerjee, Mar 3, 2004, in forum: C Programming
    Replies:
    5
    Views:
    346
    mehul raval
    Mar 4, 2004
  4. Replies:
    2
    Views:
    527
  5. Carsten Fuchs
    Replies:
    45
    Views:
    1,607
    James Kanze
    Oct 8, 2009
Loading...

Share This Page