Bugfix for 127 < d < 256.

Java castes bytes to signed ints, so if d > 127, it comes out
negative.  This is handled by a simple switch (called once per run).