3 ms·
Ruby's % operator behaves the same way, for both integer and float values. A positive-only modulus function is useful for wrapping angles. This bit me a week
by nitrogen 5y ago
Ruby's % operator behaves the same way, for both integer and float values. A positive-only modulus function is useful for wrapping angles. This bit me a week or two ago when I was porting audio algorithms from Ruby to C, and had to implement a positive modulus function[0].
[0] https://github.com/mike-bourgeous/mb-sound/blob/a8eb1232ae35e501948004bca3e798cfa727898c/ext/mb/fast_sound/fast_sound.c#L192 https://github.com/mike-bourgeous/mb-sound/blob/a8eb1232ae35...