% can be different with respect to sign in different implementations of C. fmod() in C is designed to work with floats.
On my system, -10 [mod 3] and -10 [% 3] in Pd work differently. [mod] outputs the positive remainder, which is 2, while % outputs the remainder with the sign of the dividend, which is -1.
[div] and [mod] form a pair. Given two numbers A and B, B*(A [div B])+(A [mod B]) = A. [%] and [/]—[int] should form a similar pair, so -10 [div 3] should yield -4, while int(-10 [/ 3]) should yield -3.
On Sat, May 7, 2016 at 6:44 PM, Miller Puckette msp@ucsd.edu wrote:
I _think_ (but am not sure) that "%" works differently on different CPU architectures.
cheers Miller
On Sat, May 07, 2016 at 06:27:33PM -0300, Alexandre Torres Porres wrote:
2016-05-07 14:53 GMT-03:00 Miller Puckette msp@ucsd.edu:
I put in a sentence to scare users away from "%". Use "mod" instead :)
oh, but I can't see it, so you just did it now, right?
I know they differ for negative values input, never knew why the reason..
expr also has a "%" function that behaves in the same way as the [%] object, to make things more confusing, a "fmod" function in expr also behaves in the same was as "%", but for float arguments, and not like vanilla's [mod]
in max, [%~] (or [modulo~]) will behave the same way as "fmod" in expr, that is modulo for float arguments, which is also in agreement to pd vanilla's % - only that pd's is for ints.
With all that, what I mean to ask and say is that I can't see what's
wrong
with [%] - the odd one out seems to be [mod].
what do you say?
cheers
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list