[PD] pow/pow~ and negative input, a fix proposal

Alexandre Torres Porres porres at gmail.com
Tue May 8 20:07:33 CEST 2018

Hi, I'm basically reviving a discussion I found on the list archive from 5
years ago, see:

Not much came out of it besides the assumption this could be a concern to
prevent inf/nan results!

As in:

|[pow 0.5]

I can see that, because we have other examples like that in Pd, like
log/log~ outputing -1000 for <= 0 inputs.

But still, that's not a good reason to prevent something like:

[-1 (
|[pow 2]

So I did a Pull Request where I still make it output "0" when pow/pow~
would give 'inf' or 'nan' but still allow us to calculate the power of
negative numbers. Here it is:
https://github.com/pure-data/pure-data/pull/356 (In another commit, 'm also
proposing log to behave like log~ anyway)

I come to the list to query if anyone thinks there might be a concern in
expanding the behaviour of pow/pow~

I personally cannot think of any use case where someone relies on pow(-1,
2) generating "0", it just seems wrong to me (i.e. a bug) and allowing it
to do that wouldn't break things.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20180508/c1679e98/attachment.html>

More information about the Pd-list mailing list