1

I have a float number i want that it should display only two digits after decimal like if its is 1.566666 it simply show 1.56

I am using this way for float in my code

    float ProfitForCerenia=costtoclient/markup;

float totalProfit=costtoclient-ProfitForCerenia;
user1392981
  • 27
  • 1
  • 5
  • possible duplicate of [Make a float only show two decimal places](http://stackoverflow.com/questions/560517/make-a-float-only-show-two-decimal-places) –  May 15 '12 at 11:57
  • You probably should not use floats for money. Generally it's a good idea to use integers, as you wont get any rounding errors on addition / subtraction. – lucas clemente May 15 '12 at 11:58

1 Answers1

11

I assume you want a NSString with your number:

[NSString stringWithFormat:@"%.02f", floatVal];
jimpic
  • 5,360
  • 2
  • 28
  • 37