A: 

I used wrong parse param. I should not use big_word instead of big_dword.

Hai
A: 

The big_word parser matches a big-endian word (16 bits), while big_dword will match what you want (big-endian dword, 32 bits). But I don't think it to be a good idea to use a float as the attribute to the binary parser, you might not get what you expect.

hkaiser
Thank you, you are right. I didn't get what I expect. So should I parse it as unsigned 32bit int first, then static_cast it as float? Or there is any better way to finish this job? Do I need directly swap the bytes for float or double ?
Hai
Generally (well, in IEEE-754), float and double are not endian sensitive, their layout is the same on all architectures. If you need to input/output the binary (bit) representation of floats and doubles using Spirit you probably need to do something ugly like: float f; *reinterpret_cast<uint32_t*>( or some nasty tricks with a union. But now as I think of it, I believe the best solution would be to add bin_float and bin_double parsers/generators to Spirit. Those are currently missing. I might just write an article on the Spirit website about this...
hkaiser
You are right. I don't need Spirit to deal with float numbers. I found my answer here. http://stackoverflow.com/questions/1695681/reading-from-and-writing-to-the-middle-of-a-binary-file-in-c-c
Hai