Modulo , remainder

Official support for: loomer.co.uk
User avatar
gentleclockdivider
KVRAF
3217 posts since 22 Mar, 2009 from gent

Post Wed Aug 26, 2020 3:03 pm

Two modules doing the same thing
What am I missing ?
Eyeball exchanging
Soul calibrating ..frequencies

colin@loomer
KVRAF
2175 posts since 25 Aug, 2003 from Bournemouth, UK

Post Thu Aug 27, 2020 12:33 am

A topic likely more complex than you would have at first thought! https://en.wikipedia.org/wiki/Modulo_operation

It only makes a difference when dealing with negative numbers. Essentially, modulo uses floor division and so the output has the sign of the divisor (the second argument). Remainder uses truncated division and the output has the sign of the dividend (the first argument). Try it with -11, 3, which has a modulo of 1, and remainder of -2.
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

User avatar
gentleclockdivider
KVRAF
3217 posts since 22 Mar, 2009 from gent

Post Thu Aug 27, 2020 2:59 am

Yep , noticed this shortly after I posted
Sorry for the forum pollution :)
Eyeball exchanging
Soul calibrating ..frequencies

colin@loomer
KVRAF
2175 posts since 25 Aug, 2003 from Bournemouth, UK

Post Thu Aug 27, 2020 3:04 am

No problem: modulo vs remainder is a source of confusion in many programming languages. It's good to have it here 'on record', as it were.
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

colin@loomer
KVRAF
2175 posts since 25 Aug, 2003 from Bournemouth, UK

Post Wed Sep 02, 2020 7:50 am

I've also updated the inline reference help to make this distinction clear, as it's not obvious (nor, in fact, constant across programming languages) which operation is which!
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.

Return to “Loomer”