Question: I was curious to know how I can round a number to the nearest whole number. For instance, if I had:

```
int a = 59 / 4;

```

which would be 14.75 if calculated in floating point; how can I store the result as 15 in "a"?

Answer: 
You should instead use something like this:

```
int a = (59 - 1)/ 4 + 1;

```

I assume that you are really trying to do something more general:

```
int divide(x, y)
{
   int a = (x -1)/y +1;

   return a;
}

```

x + (y-1) has the potential to overflow giving the incorrect result; whereas, x - 1 will only underflow if x = min\_int...
Borrowing from @ericbn I prefere defines like

```
#define DIV_ROUND_INT(n,d) ((((n) < 0) ^ ((d) < 0)) ? (((n) - (d)/2)/(d)) : (((n) + (d)/2)/(d)))
or if you work only with unsigned ints
#define DIV_ROUND_UINT(n,d) ((((n) + (d)/2)/(d)))

```