I have a simple app that I am trying to make add two NSStrings together and produce the value in a label.
NSString *one= @"0.00";
NSString *two= @"20.15";
NSString *total = [[NSString alloc] initWithFormat:@"%d",[one integerValue] + [two integerValue]];
label.text = [NSString stringWithFormat:@"%@",total];
This works fine except I want it to take in account the numbers past the decimal. The output becomes 20 and not 20.15.
Use floats instead of integers
If you want to specify 2 decimal places, replace
%fwith%.2fNote,
[two integerValue]evaluates to20in your example. You lose the decimal precision from that point on.