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: David Alter <email@hidden>
- Date: Fri, 18 Apr 2008 10:27:12 -0700
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
val =-1;
unsigned long long temp = (unsigned long long)val;
printf ( "unsigned long long=%llu \n", (unsigned long long)temp );
printf ( "unsigned=%u \n\n", (unsigned int)temp );
results
unsigned long long=18446744073709551615
unsigned=4294967295
I hope this helps
enjoy
dave
On Apr 17, 2008, at 4:01 PM, George Warner wrote:
On Thu, 17 Apr 2008 14:45:22 -0700, David Alter <email@hidden
>
wrote:
I have a double that is assigned a negative value. I get different
results if it is cast to an unsigned int depending on if I'm on PPC
or
Intel. The PPC values look correct.
Here is the code for may test
double val = -1;
printf ( "unsigned long long=%llu \n", (unsigned long long)val );
printf ( "unsigned=%u \n\n", (unsigned int)val );
Here is the results on PPC
unsigned long long=4294967295
unsigned=4294967295
Here is the results on Intel
unsigned long long=18446744073709551615
unsigned=0
Casting into signed numbers works the same on both PPC and Intel.
Any ideas. It sure would be nice it worked the same on both platforms
When I ran your code (on Intel) I got:
unsigned long long=0
unsigned=0
Then I noticed I the "Active Build Configuration" was "Release";
when I
switch this to "Debug" I got the same output as you.
You may want to check this on PowerPC to see if that makes a
difference for
you. Also you may want to use the flag that forces Intel to use the
SIMD
instructions for all floating point (IIRC: -mfpmath=sse).
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
_______________________________________________
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