Code Poetry
and Text Adventures

by catid posted (>30 days ago) 6:02pm Fri. Mar 2nd 2012 PST
Just a little interesting code snippet:

    To compute (j - 1) % 255, given that j is already in the range 0..254:

      --j;
      j = (u8)(j + (j >> 8));

    To compute (j + 1) % 255, given that j is already in the range 0..254:

      ++j;
      j = (u8)(j + ((j + 1) >> 8));
last edit by catid edited (>30 days ago) 3:52am Sun. Mar 4th 2012 PST