• 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
Re: if statement
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: if statement
      • From: "Sean McBride" <email@hidden>
References: 
 >if statement (From: Nathan <email@hidden>)
 >Re: if statement (From: Nathan <email@hidden>)

  • Prev by Date: Re: Cocoa Classes from C++?
  • Next by Date: Re: Cocoa Classes from C++?
  • Previous by thread: Re: if statement
  • Next by thread: Re: if statement
  • Index(es):
    • Date
    • Thread