0

I am trying to divide integer value by float, however getting wrong value. Please consider below example,

int a = 2;
float b = 10.0;
float result = a/b;

We are getting result as 0.200000003 instead of 0.2. I want use resulted value for other calculation. enter image description here Please let me know how to solve this issue.

Nandha
  • 6,746
  • 2
  • 23
  • 33

1 Answers1

0

Use as for this

NSString *timeString = [NSString stringWithFormat:@"%.1f", result];
Jitendra Modi
  • 2,344
  • 12
  • 34