Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
86 user(s) are online (77 user(s) are browsing Forums)

Members: 2
Guests: 84

LiveForIt, Mr_byte, more...

Support us!

Headlines

 
  Register To Post  

Reading "double" values from an Intel file
Not too shy to talk
Not too shy to talk


See User information
Hello

I am having some trouble to read a file coming from an PC application (so a binary with Intel ordering)
Some data are stored as "double" 64 bits but they dont seems to be the same as "double" in Motorola world

I have tested several byte-ordering without success ...
Any example code for converting that ??

Alain Thellier

Go to top
Re: Reading "double" values from an Intel file
Not too shy to talk
Not too shy to talk


See User information
@thellier
It should be the reverse byte-order, just like it is for other types. If you tried that and if it doesn't work then you most likely simply got a typo in your shift / OR / AND orgy.
This should do:

#define ANTI_ENDIAN_64(a) \
(((a) << 56) | \
(((a)<<40) & 0x00FF000000000000ull) | \
(((a)<<24) & 0x0000FF0000000000ull) | \
(((a)<<8) & 0x000000FF00000000ull) | \
(((a)>>8) & 0x00000000FF000000ull) | \
(((a)>>24) & 0x0000000000FF0000ull) | \
(((a)>>40) & 0x000000000000FF00ull) | \
((a) >> 56))


Or use a union of double and 8 chars and simply swap char[x] and char[7-x] (x>=0, x<4).

Go to top
Re: Reading "double" values from an Intel file
Quite a regular
Quite a regular


See User information
@thellier

Are you on 68k or PPC?

68k uses 80-bit floats internally. Not sure how the compilers implement double in this case. I think x86 also uses 80-bit floats, but PPC and probably x64 uses 64-bit floats.

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project