All pastes #262172 Raw Edit

Mine

public text v1 · immutable
#262172 ·published 2006-11-30 06:21 UTC
rendered paste body


#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;
}