C
Chris N. Hinds
I have a question regarding accessing long long ints in unions. I have
constructed a union with a double, two ints in a structure, and a long
long int. When the double is loaded with a floating-point constant, the
double is loaded correctly, and the two ints in the structure reflect
the double correctly when printed as hex values. However, when the long
long is printed as a hex value (using %016x) it prints 8 zeros then the
upper 32-bits of the double.
What am I doing wrong here? I want to be able to manipulate the double
using the long long ultimately using bit selects (that didn't work
either...).
Thanks for any help!
chris
The code for the union and the print statements and output follow.
The following union
typedef union uDblLLInts {
struct {
int iDHi;
int iDLo;
};
double dbl;
unsigned long long int llD;
} DblLLInts;
when initialized with:
DblLLInts DblA;
DblA.dbl = 1.000005;
prints this:
dbl is 1.000005e+00
int parts are 3ff000053e2d6239
long long is 000000003ff00005
for these printfs:
printf(" dbl is %e\n", DblA.dbl);
printf(" int parts are %08x%08x\n", DblA.iDHi, DblA.iDLo);
printf(" long long is %016x\n", DblA.llD);
--
*******************************************************
Chris N. Hinds <>< www.arm.com
ARM Austin Design Center (e-mail address removed)
(512) 314-1055 (Direct)
(512) 327-9249 (Front Desk)
(512) 314-1078 (Fax)
*******************************************************
This e-mail message is intended for the addressee(s) only and may
contain information that is the property of, and/or subject to a
confidentiality agreement between the intended recipient(s), their
organization and/or the ARM Group of Companies. If you are not
an intended recipient of this e-mail message, you should not read,
copy, forward or otherwise distribute or further disclose the
information in it; misuse of the contents of this e-mail message
may violate various laws in your state, country or jurisdiction.
If you have received this e-mail message in error, please contact
the originator of this e-mail message via e-mail and delete all
copies of this message from your computer or network, thank you.
constructed a union with a double, two ints in a structure, and a long
long int. When the double is loaded with a floating-point constant, the
double is loaded correctly, and the two ints in the structure reflect
the double correctly when printed as hex values. However, when the long
long is printed as a hex value (using %016x) it prints 8 zeros then the
upper 32-bits of the double.
What am I doing wrong here? I want to be able to manipulate the double
using the long long ultimately using bit selects (that didn't work
either...).
Thanks for any help!
chris
The code for the union and the print statements and output follow.
The following union
typedef union uDblLLInts {
struct {
int iDHi;
int iDLo;
};
double dbl;
unsigned long long int llD;
} DblLLInts;
when initialized with:
DblLLInts DblA;
DblA.dbl = 1.000005;
prints this:
dbl is 1.000005e+00
int parts are 3ff000053e2d6239
long long is 000000003ff00005
for these printfs:
printf(" dbl is %e\n", DblA.dbl);
printf(" int parts are %08x%08x\n", DblA.iDHi, DblA.iDLo);
printf(" long long is %016x\n", DblA.llD);
--
*******************************************************
Chris N. Hinds <>< www.arm.com
ARM Austin Design Center (e-mail address removed)
(512) 314-1055 (Direct)
(512) 327-9249 (Front Desk)
(512) 314-1078 (Fax)
*******************************************************
This e-mail message is intended for the addressee(s) only and may
contain information that is the property of, and/or subject to a
confidentiality agreement between the intended recipient(s), their
organization and/or the ARM Group of Companies. If you are not
an intended recipient of this e-mail message, you should not read,
copy, forward or otherwise distribute or further disclose the
information in it; misuse of the contents of this e-mail message
may violate various laws in your state, country or jurisdiction.
If you have received this e-mail message in error, please contact
the originator of this e-mail message via e-mail and delete all
copies of this message from your computer or network, thank you.