<div>You're right: in C99 and for i=0, LHS and RHS differ. I don't know what I was thinking, so forget my very last formula. You wish your code to work for all complying compilers.<br></div><div><br data-mce-bogus="1"></div><div>Notice that a bounding box consisting of one point (whether this is the point with the coordinates (0,0) or any other point, e.g., (2,5)) is a perfect 0-dimensional bounding box around this very point. Making the box any larger would include infinitely many new points and increase the dimension to 1. So no, don't use my RHS (at least not for this reason).<br></div><div><br></div><blockquote><div>11.03.2024, 18:59, Tomas Rokicki <<a href="mailto:rokicki@gmail.com" target="_blank" rel="noopener" data-mce-href="mailto:rokicki@gmail.com">rokicki@gmail.com</a>></div><div id="part2" class="messageBodyContainer"><div class="messageBody"><div class="RMCnxtG8riKup"><div dir="ltr">> ceil(i * a / b) = i / b * a + (i % b * a - 1) / b + 1<div><br></div><div>This fails if i=0 since division in C is (currently) truncate-towards-zero, so we end up with 0 + 0 + 1 which is 1, when</div><div>for input of 1 we want 0.</div><div><br></div><div>Not that it matters since a bounding box of 0 0 0 0 is nonsense anyway.  And one might argue that this is actually</div><div>a better answer since if somehow the paper size did get set to zero, we'd at least have a non-zero bounding box.</div></div></div><br></div></div></blockquote>