float theFloat = 1.23456;
int rounded = lroundf(theFloat); NSLog(@"%d",rounded);
int roundedUp = ceil(theFloat); NSLog(@"%d",roundedUp);
int roundedDown = floor(theFloat); NSLog(@"%d",roundedDown);
// Note: int can be replaced by float
How to round off float value
最新推荐文章于 2024-09-23 15:30:00 发布