How to round CGFloat
Posted
by Johannes Jensen
on Stack Overflow
See other posts from Stack Overflow
or by Johannes Jensen
Published on 2010-04-19T11:57:53Z
Indexed on
2010/04/19
12:13 UTC
Read the original article
Hit count: 573
I made this method
+ (CGFloat) round: (CGFloat)f {
int a = f;
CGFloat b = a;
return b;
}
It works as expected but it only rounds down. And if it's a negative number it still rounds down.
This was just a quick method I made, it isn't very important that it rounds correctly, I just made it to round the camera's x and y values for my game.
Is this method okay? Is it fast? Or is there a better solution?
© Stack Overflow or respective owner