Accum rounding error

Dan Laüt's icon

Context:
A routine to accumulate fractional event durations (< 1 ms), such as result from combinations of BPM, nominal duration, dotting, triplets and phrasing. If the accumulated value >=1, add 1 ms to the event duration and subtract 1 from the value in the accumulator.

Discovery: if you add 3x 0.3333... to the accumulator, it outputs 1., but a subsequent test n >= 1. yields 0. You have to set the test to n >= 0.9999...

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

"Discovery: if you add 3x 0.3333... to the accumulator, it outputs 1."

it does not.

flonum fooled you; expand its box and you get 0.999999