Hans Roels wrote:
Hello,
If you want to calculate the modulo of a negative number, you get a different result if you use the 'mod' object or 'expr' with %.
-1 4 | | mod | 3
-1 4 | | expr $f1 % $f2 | -1
I guess this is a bug in expr ?
you also get a different result if you use [mod] or [%]. it's a feature.
fgmasdr IOhannes
Hans r
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
maybe someone could explain _what_ the difference is? that would be enlightening vor everybody.
I think that since Miller is a self-described math geek, the difference is that [mod] behaves like the mathematical (mod n). [%] is the modulo operator used by computer science.
If my memory serves me, in number theory and abstract algebra, the m (mod n) notation is used to define a subset of the integers (called a congruence class) which contains n-1 elements.
For example, 5 (mod 3) == 2. Likewise, -5 (mod 3) == -2 (mod 3) == 1 (mod 3) == 1. Note that my use of == here represents congruence and not necessarily equality.
See http://en.wikipedia.org/wiki/Modular_arithmetic for a much more informed discussion of this topic.
~Kyle
On Tue, Oct 14, 2008 at 7:40 AM, Max abonnements@revolwear.com wrote:
maybe someone could explain _what_ the difference is? that would be enlightening vor everybody.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list