in reply to condensing code

Look at POSIX specifically floor and ceil and at int, those plus a simple division should see you right.

jdtorono