# round to larger

This topic is 4723 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;

• 22
• 10
• 19
• 15
• 14
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!