Weird calculation
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