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: George Warner <email@hidden>
- Date: Thu, 17 Apr 2008 16:01:47 -0700
- Thread-topic: double cast to unsigned int gets different results on PPC
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