Re: double cast to unsigned int gets different results on PPC
Re: double cast to unsigned int gets different results on PPC
- Subject: Re: double cast to unsigned int gets different results on PPC
- From: Marshall Clow <email@hidden>
- Date: Mon, 21 Apr 2008 12:34:44 -0700
At 8:58 AM +1000 4/18/08, Chris Suter wrote:
At 10:27 AM -0700 4/18/08, David Alter wrote:
I think you're straying into an area of undefined behaviour. My
interpretation of the C99 standard is that the result is undefined.
Just a little more info. If I cast into a unsigned long long first
then cast into an unsigned int I get the correct result on Intel for
unsigned int. Here is the code
David -
To quote Inigo Montoya - "I do not think that word means what you
think it means." ;-)
There is no "correct result" for this operation.
That's what "undefined behaviour" is all about.
double val = -1;
printf ( "unsigned long long=%llu \n", (unsigned long long)val );
printf ( "unsigned=%u \n\n", (unsigned int)val );
--
-- Marshall
Marshall Clow Idio Software <mailto:email@hidden>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden