Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
118 user(s) are online (96 user(s) are browsing Forums)

Members: 0
Guests: 118

more...

Support us!

Recent OS4 Files
OS4Depot.net






Reading "double" values from an Intel file
Not too shy to talk
Joined:
2011/6/3 13:49
Posts: 264
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

   Report Go to top

Re: Reading "double" values from an Intel file
Not too shy to talk
Joined:
2015/6/11 9:51
From Cologne
Posts: 378
@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).

   Report Go to top

Re: Reading "double" values from an Intel file
Not too shy to talk
Joined:
2008/5/2 13:14
From Sweden
Posts: 499
@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++
   Report Go to top





[Advanced Search]



Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project