Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Range of 32 bit values



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:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.