How to round double value in objective c if the value is 1.66 it show value to 1.55 there is missing a point value which makes a difference if the calculations are higher ?
self.priceLabel.text = [NSString stringWithFormat:@"%0.2f",totalPrice];
i have used multiple others things including formatter but this issue remain same
calculations from calculator show value like 293.76 but from this way it show value 293.75 i need the value to be 293.76
Here is something to illustrate.
All looks good!? What is the problem?
time passes
In fact, I can see lots of trouble. Not sure if this is what is bugging you, but e.g. in the output it shows
The last
2.72should have been a2.73but, again this is a complex issue. Here is a simple way to solve it - add a tolerance as in the example below.This does not directly address the complexities and there are cases where this will fail as well, but it will go a long way to getting the job done, e.g. now the output reads