Thanks a lot for the explanation. Would it be possible to add a help patch to pd, something like the one attached? div, mod, and % currently default to otherbinops-help.pd but aren't included in that patch.
-Jonathan
--- On Fri, 2/6/09, Mathieu Bouchard matju@artengine.ca wrote:
From: Mathieu Bouchard matju@artengine.ca Subject: Re: [PD] div vs. / & i To: "Jonathan Wilkes" jancsika@yahoo.com Cc: pd-list@iem.at Date: Friday, February 6, 2009, 4:12 PM On Fri, 6 Feb 2009, Jonathan Wilkes wrote:
But I just noticed while scrolling in a number box
that they aren't the same when the dividend is negative. In the source for [div], I see this before doing the division: if (n1 < 0) n1 -= (n2-1); I feel like I'm missing something obvious. Why does [div] behave this way?
So that (x div y)*y + (x mod y) = x
So div is complementary to mod.
Also, int(x / y)*y + (x % y) = x
So / with i is complementary to %.
And div,mod behave the way that they do so that (x+y) mod y = x mod y (x+y) div y = (x div y) + 1
Whereas div with i and % do not, when x and x+y have different signs.
_____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec