Divide by 3 and Round up (If need be) C#

Subby picture Subby · Aug 5, 2012 · Viewed 10.4k times · Source

I have come to a point in my game where I have to implement a feature which divides a number by 3 and makes it a whole integer. i.e. not 3.5 or 2.6 etc....

It was to be a whole number, like 3, or 5.

Does anyone know how I can do this?

Answer

Inisheer picture Inisheer · Aug 5, 2012
Math.Round(num / 3);

or

Math.Ceiling(num / 3);

or

Math.Truncate(num / 3);