On Thu, Aug 19, 2010 at 13:14:21 -0500,
Richard Shaw <hobbes1069(a)gmail.com> wrote:
Ok, I understand what you're doing now, but I still think I'm right.
If you use straight integer math, it does not round up for the last
block. It does not round at all, it just drops the remainder. The
easiest solution probably is to just add 1 to whatever size /
BLOCK_SIZE returns.
The normal sematic for this kind of thing with integer division is:
(size + BLOCKSIZE - 1) / BLOCK_SIZE
(Unless integer overflows are possible.)
Otherwise if size is a multiple of BLOCK_SIZE the result would be 1 too large.