Use lroundf(x) instead of x+0.5 to int.