-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm trying to get [pow 2] from -0.019022952498528478. because it is negative, [pow 2] will just return 0 unfortunately. IOhannes suggested in a thread from 2013 to use [expr pow($f1, 2)] instead. This returns 0.000361872
however, in Python and my on-screen pocket calculator I get
so apart from the 32 bit float, shouldn't the result be negative?
m.
On Sat, Jun 6, 2015 at 7:44 PM, Max abonnements@revolwear.com wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I'm trying to get [pow 2] from -0.019022952498528478. because it is negative, [pow 2] will just return 0 unfortunately. IOhannes suggested in a thread from 2013 to use [expr pow($f1, 2)] instead. This returns 0.000361872
however, in Python and my on-screen pocket calculator I get
- -0.019022952498528478**2
- -0.0003618727217612709
so apart from the 32 bit float, shouldn't the result be negative?
As far as the math is concerned, when you multiply two negative numbers, you get a positive, right? why expect a negative then? Maybe I'm missing something obvious here, dunno...
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Max,
On 07/06/15 00:44, Max wrote:
I'm trying to get [pow 2] from -0.019022952498528478. however, in Python and my on-screen pocket calculator I get -0.019022952498528478**2 -0.0003618727217612709
so apart from the 32 bit float, shouldn't the result be negative?
Here's what I get with Python:
$ python
pow(-0.019022952498528478, 2)
0.0003618727217612709
-0.019022952498528478 ** 2
So the "**" operator behaves differently from "pow(x, 2)".
Cheers,
Chris.
On 07/06/15 01:38, Chris McCormick wrote:
So the "**" operator behaves differently from "pow(x, 2)".
It's more likely that:
- x ** 2
means:
- (x ** 2)
not:
(- x) ** 2
On 07/06/15 08:57, Claude Heiland-Allen wrote:
- x ** 2
means: - (x ** 2) not: (- x) ** 2
Ah, of course! That's subtle. Thanks Claude.
This is why everyone should just use LISP. ;)
Cheers,
Chris.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi claude, thank you for the enlightenment. m.
On 2015년 06월 07일 09:57, Claude Heiland-Allen wrote:
On 07/06/15 01:38, Chris McCormick wrote:
So the "**" operator behaves differently from "pow(x, 2)".
It's more likely that:
- x ** 2
means:
- (x ** 2)
not:
(- x) ** 2
See: https://en.wikipedia.org/wiki/Order_of_operations
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list