This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
question on double to int conversion
- From: Jaeyoun Chung <jay at kldp dot org>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 21 May 2004 10:55:43 +0900
- Subject: question on double to int conversion
- Reply-to: jay at kldp dot org
Hello,
This is not directly related to gcc but I think you guys knows better.
I'm testing double to int conversion while implementing d2i.
int
main (int ac, char *av[])
{
double x;
double y;
x = 23840923485098340850403409e2;
y = -x;
printf ("%x\n", (int)x);
printf ("%x\n", (int)y);
}
To be ieee 754 compliant, '%x' output should be 7fffffff and 80000000,
respectively. This works in sparc machine quite ok. But in Intel(R) Pentium(R)
4 the output is 80000000 and 80000000.
The thing is intel cpu is supposed to be ieee 754 compliant, is there any
mechanism to adjust the cpu mode so that the result is 7fffffff and 80000000?
Thanks in advance.