Re: Converting string equation to int
Re: Converting string equation to int
- Subject: Re: Converting string equation to int
- From: Jason Jobe <email@hidden>
- Date: Fri, 11 Feb 2005 21:50:18 -0500
You could add a category to string to pass it off to the calc engine
(LGPL) for evaluation.
http://www.isthe.com/chongo/tech/comp/calc/
That would be cool!
On Feb 11, 2005, at 7:54 PM, Christopher Drum wrote:
Does anyone know a Cocoa method that will accept an equation as an
NSString and evaluate it to achieve an int (or long, or whatever). I
want to be able to do something like:
NSString *equation = @"7+5";
int x = [equation intValue];
NSLog(@"equation evaluates to: %i", x);
Unfortunately, intValue doesn't seem to look at a string as an
evaluatable equation, and I get 7 as the result rather than 12. Cocoa
seems to stop as soon as it reaches a non-numeric character.
I feel like there is some easy way to get this to work that I am
overlooking. Any ideas?
------------------------------------------------------------------
Christopher Drum
http://homepage.mac.com/christopherdrum
Check out FileWrangler, my five-star rated (MacUpdate, VersionTracker)
Cocoa app written in Objective-C for the batch renaming of files.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
- jason
email@hidden
_______________________________________________
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