Re: if statement
Re: if statement
- Subject: Re: if statement
- From: Graham Cox <email@hidden>
- Date: Wed, 28 May 2008 10:11:16 +1000
I see you've decided to ignore my advice about using a "proper"
parser ;-) That's OK, but you'll probably start to realise why they
are a good idea once you try and expand this to more functions (which
I presume you will eventually, since a 4-function calculator is not of
very great utility).
However, something else is a bit smelly about this code apart from the
assignment blooper.
what is OB? Is it 1, 2, 3 etc? Or is it 0.9999999999, 1.999999999....?
If the latter, what will "if (OB == 1)" produce - true or false? The
point is that floating point values have limited precision (after all,
you are trying to represent all possible numbers in just 32-bits -
they just don't all fit!).
Food for thought, I hope.
Graham
On 28 May 2008, at 7:31 am, Nathan wrote:
Third time...
On May 27, 2008, at 5:27 PM, Vincent E. wrote:
You need double equal signs in conditional statements, like:
- (IBAction)operators:(id)sender {
OB=[operatorBar floatValue];
if (OB==1) {
[operator setFloatValue: 4];
}
if (OB==2) {
[operator setFloatValue: 5];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden