Use floor(x+0.5) instead of C99's round()