return value of pow() gets rounded down if assigned to an integer

Add 0.5 before casting to int. If your system supports it, you can call the C99 round() function, but I prefer to avoid it for portability reasons.

Leave a Comment