URGENT SOLUTION NEEDED !!! DECIMAL are left forgotten in calculation !!!!
PLZ HELP ME
I'm stuck for some hours now on the following problem:
1)Got a textfield for a number that has to be divided through 100 and
multiplied by a second number after hitting a calculate box 2)I can add A
Decimal number in the textfield... 3)The result comes out as a number with
decimals but does not seem to use all the decimals from the first number
in the calculation.
Example : 2033,33 /100 * 21 becomes : 426,93 (it only looked at 2033 tot
preform the calculation and forgot the remaining 0,33)
Im kinda new to scripting in xcode and have looked everywhere. I guess
there is a simple solution im not seeing anymore after neary 8 hours of
trying??? I need to get this fixed for my brother tomorrow if possible
This is part of my viewcontroller h script:
{
IBOutlet UITextField *numOne; // First number
IBOutlet UITextField *numTwo; // Second number
IBOutlet UITextField *answer; // First number divided by 100 and
multiplied by second number
}
-(IBAction)Calculate:(id)sender; //Calculationbox
And this is the part of my view controller m script :
-(IBAction)Calculate:(id)sender{
float x = ([numOne.text floatValue]/100.00);
float c = x*([numTwo.text floatValue]);
answer.text = [[NSString alloc] initWithFormat:@"%.2f", c];
No comments:
Post a Comment