• 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
Range of 32 bit values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Range of 32 bit values


  • Subject: Range of 32 bit values
  • From: Luigi Castelli <email@hidden>
  • Date: Thu, 5 Apr 2007 14:09:34 -0700 (PDT)

Hi there,

I am on a PowerBook 2.16 GHz Intel Core Duo running Mac OS 10.4.7.
I am writing a small application with Xcode.

I have declared a variable as a 32-bit signed int.
So, the range of this variable goes from -2147483648 to 2147483647.
I multiply big float values and - after being appropriately cast -
assign them to the above variable.

Example:

int value = (int)(32768. * 65536.)    // (and bigger)

I just so happens that when the result of the multiplication exceed the
size of the value that a 32 bit int type variable is able to represent
the value is clipped to -2147483648. I have noticed that the cast
(either explicit or implicit) is what causes the value to be clipped,
because if I cast to a bigger value (i.e. 64 bit) then the value is
wrapped until the 64 bit maximum is reached. Then the value is clipped
again.

In any case for the algorithm I am developing I would like the int
value to be wrapped, not clipped. I would like after reaching the
value's maximum limit to go back and start again from its minimum.

Is there any flag I need to set in Xcode to achieve that or am I just
unaware of programming rules ? I remember in Codewarrior values were
always wrapped by default.

Thanks for any help or suggestion.

- Luigi


------------------------------------------------------------
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION.  ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED.  IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT email@hidden AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC1-207.
------------------------------------------------------------




____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
 _______________________________________________
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

  • Prev by Date: Re: MallocDebug problem
  • Next by Date: libgmalloc on MacBook Pro
  • Previous by thread: Re: MallocDebug problem
  • Next by thread: Re: Range of 32 bit values
  • Index(es):
    • Date
    • Thread