Mine
public text v1 · immutable
#define STEP 0x8000000
#define HALF_STEP (STEP >> 1)
#define HYST 0x5000000
#define HALF_HYST (HYST >> 1)
signed int accum;
accum += addval;
if ( accum > (HALF_STEP+HALF_HYST) ) {
accum -= STEP;
output an UP step;
} else if ( accum < -(HALF_STEP+HALF_HYST) ) {
accum += STEP;
output a DOWN step;
}