This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

question on double to int conversion


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]