• 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
Weird calculation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird calculation


  • Subject: Weird calculation
  • From: Thilo Ettelt <email@hidden>
  • Date: Thu, 24 Jan 2002 11:23:54 +0100

Hi!

I'm new to Cocoa and so I'm practising a bit. I wrote a little app, which should give me the result of two values. The user can select the kind of calculation (+,-,*,/) via popupmenubutton.

That's the code of it's action:

--

float wert1, wert2, loesung;

wert1 = [value1 floatValue];
wert2 = [value2 floatValue];

switch([list indexOfSelectedItem]) {
case 0:
loesung = wert1 + wert2;
case 1:
loesung = wert1 - wert2;
case 2:
loesung = wert1 * wert2;
case 3:
loesung = wert1 / wert2;
}

[calc setFloatValue:loesung];

--

Please note that "loesung" stands for the result, "wert1" and "wert2" for value 1 and 2. "calc" is the textfield for the result.

The strange thing (for me) is that I always get wrong results!
Can somebody help me?


Cheers, Thilo


  • Follow-Ups:
    • Re: Weird calculation
      • From: "Erik M. Buck" <email@hidden>
    • Re: Weird calculation
      • From: Andreas Doerr <email@hidden>
    • Re: Weird calculation
      • From: Nick Müller <email@hidden>
  • Prev by Date: Re: SplitView probbs, hmm...
  • Next by Date: Re: Faster way to draw strings?
  • Previous by thread: Re: Cocoa and Calculus
  • Next by thread: Re: Weird calculation
  • Index(es):
    • Date
    • Thread