All pastes #262177 Raw Edit

Something

public text v1 · immutable
#262177 ·published 2006-11-30 06:28 UTC
rendered paste body
#define STEP  0x70000000
#define HALF_STEP (STEP >> 1)
#define HYST  0x50000000
#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;
}