replace floor hack with Math.floor()

Rounding a value - 0.5 is a common hack to work around the lack of a
floor function. Since Math.floor() exists, we will use it instead.