Re: NSNumber math?
Re: NSNumber math?
- Subject: Re: NSNumber math?
- From: "Keith Ray" <email@hidden>
- Date: Thu, 11 May 2006 07:38:58 -0700
get the FScript sources and look at FSNSNumber.m and .h
http://www.fscript.org/
On 5/11/06, Christopher Hickman <email@hidden> wrote:
I take it that NSNumber instances are immutable, given that I can't find any
way to do math with them directly.
For example, this:
/* code snippet 1 */
int x = 1;
int y = 2;
int z;
z = x+y; //z == 3
/* end code snippet */
When using NSNumbers has to go to the way more complex:
/* code snippet 2 */
NSNumber *x = [NSNumber numberWithInt:1];
NSNumber *y = [NSNumber numberWithInt:2];
NSNumber *z;
z = [NSNumber numberWithInt:[x intValue] + [y intValue]]; //z == 3 as
NSNumber
/* end code snippet */
z = x+y is an error for the second one, since that would just be pointer
math--not good ;)
Are there some methods for performing math on NSNumbers that I'm just not
seeing in the docs? Something like -[NSNumber add:] or -[NSNumber
subtract:], etc.? Or do I have to pull the scalars out of their comfortable
little wrappers each time I have to do some math?
Topher
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
C. Keith Ray
<http://homepage.mac.com/keithray/blog/index.html>
<http://homepage.mac.com/keithray/xpminifaq.html>
<http://homepage.mac.com/keithray/resume2.html>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >NSNumber math? (From: "Christopher Hickman" <email@hidden>) |