Search code examples
c#divide

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


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?


Solution

  • Math.Round(num / 3);
    

    or

    Math.Ceiling(num / 3);
    

    or

    Math.Truncate(num / 3);