• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: double cast to unsigned int gets different results on PPC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: double cast to unsigned int gets different results on PPC


  • Subject: Re: double cast to unsigned int gets different results on PPC
  • From: Chris Suter <email@hidden>
  • Date: Fri, 18 Apr 2008 08:58:18 +1000


On 18/04/2008, at 7:45 AM, David Alter 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.

I think you're straying into an area of undefined behaviour. My interpretation of the C99 standard is that the result is undefined.


To get defined portable behaviour cast to int first:

i.e.  intVal = (unsigned)(int)doubleVal;

- Chris

_______________________________________________
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


References: 
 >double cast to unsigned int gets different results on PPC (From: David Alter <email@hidden>)

  • Prev by Date: Re: G4 867mhz, Leopard, and XCode 3
  • Next by Date: re: double cast to unsigned int gets different results on PPC
  • Previous by thread: double cast to unsigned int gets different results on PPC
  • Next by thread: Re: double cast to unsigned int gets different results on PPC
  • Index(es):
    • Date
    • Thread