Hello All,
I'm totally new to pd and so far I am having fun.
I have a specific problem but my question is more general.
I have written a sub-patch to perform the "Sign" function that is missing from pd (if it is not and I just missed it, it's a good exercise anyways). It takes any number and output -1 for negative numbers, 0 for 0 and +1 for positive numbers.
It works well except when I input the first negative number, that is, when the previous number was >= 0, the output is, wrongly, 0. From the second negative number on, everything works.
I tracked it down to a [+ ] object. Is seems that it adds the current left inlet input to the PREVIOUS right inlet input. Please see patch "Sign 1".
If I change the order in which I connect things the behavior does not seem to change.
I found a workaround, but it is an ad hoc one, so my function now works (Sign 2).
But I suspect this thing of hot/cold is a common problem and I was wondering if there is a more general solution to make my first patch work.
I am not sure, for instance, if [trigger] would be useful here and how to implement it.

Ah, and if the Sign function does already exist, please let me know, I am a big fan of NOT reinventing the wheel :)

Thanks

http://www.pdpatchrepo.info/hurleur/sign_1.pd