Simon Josefsson <[EMAIL PROTECTED]> writes: > Bruno Haible <[EMAIL PROTECTED]> writes: > >> Simon Josefsson wrote: >> >>> + l = dkLen / hLen; >>> + if (dkLen % hLen) >>> + l++; >> >> An equivalent but faster code is: >> >> l = ((dkLen - 1) / hLen) + 1; > > Perhaps for clarity we could change it into: > > #define CEIL_DIV(a,b) (((a) - 1) / (b)) + 1 > l = CEIL_DIV (dkLen, hLen); > > What do you think?
That implementation of CEIL_DIV doesn't work in general, e.g., if dkLen has the minimum value for its type. So I wouldn't use it, at least not without a comment saying that it's not safe in general. Bruno's rewrite is safe because dkLen cannot possibly be zero here. _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib