karl3ļ¼ writeme.com wrote:
> > xkcd
> > off-by-40-or-50 errors

> > cpython

> draft

> #include <pycore_pylifecycle.h>
> int adjust(type * val) {
>   unsigned uint8_t rnd;
>   int status, adj;
>   do {
>     status = _PyOS_URandom(&rnd, 1);
>     if (status) { return status; }
>   } while (rnd >= 242);
>   adj = int(rnd % 22) - 11

#include <pycore_pylifecycle.h>
int adjust(type * val) {
  unsigned uint8_t rnd;
  int status, adj;
  do {
    status = _PyOS_URandom(&rnd, 1);
    if (status) { return status; }
  } while (rnd >= 242);
  rnd %= 22;
  adj = (rnd & 1) ? -(int)(rnd>>1) - 40 : (rnd>>1) + 40;
  *val += adj;
}

there's my draft! 0706!

maybe put something like that in a header file and see if can use it in files 
like Python/bytecodes.c

Reply via email to