Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If n is not within k of the maximum unsigned integer:

  i = n+k;
  do {
    i -= k;
    ...
  } while (i >= k);
If n is close enough to the maximum unsigned integer for n+k to overflow:

  i = n;
  goto skip_sub;
  do {
    i -= k;
  skip_sub:
    ...
  } while (i >= k);


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: