[PD] Negative input numbers for [pow] return 0

Joe White white.joe4 at gmail.com
Mon Apr 22 16:07:43 CEST 2013


>
> > Is this a known limitation or bug?
> it's most likely a feature that tries to protect you from things like:
> [-1(
> |
> [pow 0.5]
> |


Ahh yeah makes sense.

I'm not sure why but I always feel uneasy using [expr], maybe because of
libpd :)

[expr] does handle (-1)^0.5 with a NaN output though. Would it be possible
to add this to [pow] as well? Something like for negative base values,
non-integer exponent values would return NaN?

Additionally for [pow] to output '0' seems wrong, because that is
definitely not the answer. I've never seen NaN output elsewhere so I'm
assuming [expr] outputs a symbol and not some Pd defined NaN type (maybe?).

Thanks for the reply IOhannes!

Cheers,
Joe

On 22 April 2013 13:30, IOhannes m zmoelnig <zmoelnig at iem.at> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2013-04-22 14:19, Joe White wrote:
> > Hi,
> >
> > Just realised putting a negative number into the [pow] object
> > outputs '0'?!?
> >
> > For example if I do:
> >
> > [-1 ( | [pow 2]
> >
> > it returns 0, where I would expect it to return 1.
> >
> > Is this a known limitation or bug?
>
> it's most likely a feature that tries to protect you from things like:
>
> [-1(
> |
> [pow 0.5]
> |
>
> > Are there any work arounds if I want a variable power?
>
> urgh, i had hoped to never have to tell people to use [expr], but
> there you go:
>
> [-1\
> |
> [pack 0 2]
> |
> [expr pow($f1, $f2)]
> |
> [1\
>
> vbmdf
> IOhannes
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAlF1LW8ACgkQkX2Xpv6ydvRWDgCffaIHH1qXGqFYLlt1iiJQFW5Q
> OdEAnR8WVw+zxRKd8LWjVo95daJ/Aq6Y
> =PbB6
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20130422/55cf8924/attachment.htm>


More information about the Pd-list mailing list