How to round an float value and convert it into NSInteger value in the iPhone SDK?
objective-c
Solution
One of the following C math functions might work for you:
- double ceil(double)
- double floor(double)
- double nearbyint(double)
- double rint(double)
- double round(double)
- long int lrint(double)
- long int lround(double)
- long long int llrint(double)
- long long int llround(double)
- double trunc(double)
To get more documentation, open a terminal session and type (for example)
man lround
I pick lround as an example because I think that is the one you want.
Problem
I need to round a float value and convert it into an `NSInteger` value. For example: ``` float f = 90.909088; ``` I want the result to be 91. How to get rid of this?