I’m trying to make a UILabel count up in decimals but it’s rounding to the nearest whole. Here is the code:
int currentTime = [totalPrice.text intValue];
int newTime = currentTime + 2.50;
totalPrice.text = [NSString stringWithFormat:@"%d.00", newTime];
What am I doing wrong?
P.S. I couldn’t find any other articles on StackOverflow that were helpful.
intis a datatype that only stores integers (whole numbers). Usefloatordoublefor decimal numbers, or NSDecimalNumber if you need exact representations.