# round to larger

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, This should be simple I think, but I can't seem to think how I must do it, right now, but how do you round a number to above? example : 2,2 => 3 or 8.9 => 9 TIA

negate
round to lower
negate again

##### Share on other sites
Quote:
 Original post by da_cobraHello,This should be simple I think, but I can't seem to think how I must do it, right now, but how do you round a number to above?example : 2,2 => 3or 8.9 => 9TIA

Zing!

##### Share on other sites
it's called the ceiling function, usually ceil() or something like that.

Quote:

That doesn't work in the case where n = a.0->a.4, because you end up with a.5->a.9 truncated to a.

The actual function would be something like:

if (a != abs(a))   a = a - (a - abs(a)) + 1;

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015751
×