260 Views 2 Replies Latest reply: May 26, 2012 1:30 PM by iTryFreeApps
I have a little problem with my decimal values while I'm building an app on the iOS 5.1.1 SDK, and I don't know how to fix this. I have a meathod (I'm pretty sure it's declared in my header file under the right class), and this is the meathod:
int numOfQuarters = [quarters.text intValue];
int numOfDimes = [dimes.text intValue];
int numOfNickels = [quarters.text intValue];
int numOfPennies = [quarters.text intValue];
NSNumber *amountText = [[NSNumber alloc]initWithFloat:(numOfQuarters * 0.5) + (numOfDimes * 0.1) + (numOfNickels * 0.05) + (numOfPennies * 0.01)];
The problem is, every time I tap the sender, which is a UIButton object, the console says 1.68, but I'm setting the variable
numOfQuarters to three, and every other variable in the arithmetic problem to zero when I run it.
Please tell me how to fix this, because I'm going crazy...