Trailmakers
Arithmetics block Power(x^component) doesn't show correct value for negative x
Start with empty grid.
Place one arithmetic block with a constant value of -2 (negative two) and function sum.
Place another arithmetic block with a constant value of 2 (positive two) and function Power(x^constant). Connect first arithmetic block to this.
Place a numeric display. Connect second arithmetic block to this.
The numeric display should show 4 (positive four) but instead it shows 0 (zero).

Expected:
(-2) ^ 2 = 4
< >
Showing 1-3 of 3 comments
can't replicate. Doing (-2)^2 with x^constant does indeed result in 4. You are probably actually using constant^x with the signs reversed (so the operation ends up being the same), in which case the result of 0 is expected and mostly intended

Tl;dr, when constant<0, constant^x is in general a complex number. It's only real when x = a/b for any integer a and any odd integer b. However, unless x is an integer, it has multiple solutions and the principal one (which is what most algorithms calculate) is always complex. Since the game can only deal with real numbers, anything that results in a complex number is undefined, and to avoid blocks having to deal with NaN/Inf inputs undefined values are represented with 0. While for integer inputs the result is real, for simplicity, it was decided to always consider the result undefined when the constant is negative unless the input is exactly 0 (in which case the output is 1 by definition)
Freschu 18 Jun @ 11:54pm 
Originally posted by alvaroping1:
can't replicate. Doing (-2)^2 with x^constant does indeed result in 4. You are probably actually using constant^x with the signs reversed (so the operation ends up being the same), in which case the result of 0 is expected and mostly intended

I can appreciate you're trying to help, and I appreciate you're replicating this to check. I did however describe what I observed and I had made sure I was using Power(x^constant) when I noticed this behavior.

However in between me noticing the behavior and then writing this, and you trying to replicate, a new update was released, and I hadn't tested this again with that new update. So I just tested this again, and this time I see the outcome I expected.

I will consider this fixed by the update. 👍
Originally posted by Freschu:
Originally posted by alvaroping1:
can't replicate. Doing (-2)^2 with x^constant does indeed result in 4. You are probably actually using constant^x with the signs reversed (so the operation ends up being the same), in which case the result of 0 is expected and mostly intended

I can appreciate you're trying to help, and I appreciate you're replicating this to check. I did however describe what I observed and I had made sure I was using Power(x^constant) when I noticed this behavior.

However in between me noticing the behavior and then writing this, and you trying to replicate, a new update was released, and I hadn't tested this again with that new update. So I just tested this again, and this time I see the outcome I expected.

I will consider this fixed by the update. 👍
the update didn't change the block though, the behaviour you expected has been working since the operation was added to the arithmetic blocks (i tested all possible cases back then). You probably just misconfigured something
< >
Showing 1-3 of 3 comments
Per page: 1530 50