Ah, sorry about that! I mean, clearly you know how to make stuff actually work which is the important thing so it doesn't really matter in the grand scheme of things. But I like talking about this kind of thing and have some time on my hands so if you'll forgive me..... I don't know if this will help or just confuse things further but I think it's more useful to think of, for instance, -5 not at 0 - 5, but as -1*5. Because of order of operations the multiplication "binds" more tightly than addition/subtraction which is why the minus sticks to a specific value rather than applying to the expression as a whole. In that sense unary minus _is_ an operation and it _is_ actually distinct from subtraction. Think of a number line with positive numbers off to the right and negative numbers off to the left. Then subtraction is the _distance_ between two values, whereas negating a value reverses its _direction._ So if the number 5 is an arrow pointing five units to the right, then -5 is just that same arrow but flipped so that it now points to the left. Negate it again and we just flip its direction back to the right: -(-5) = 5. That's where my original comment came from. In the same sense that unary minus reverses the "direction" of a number, 'not' reverses the "direction" of a boolean from true to false or vice versa and it has the same operator "stickiness" as multiplication so it also applies to its specific argument rather than a whole expression. So "not A or B" is equivalent to "B or not A" because the 'not' sticks to the 'A'. But, in general, neither of those are equivalent to "not (A or B)" which applies the 'not' to the whole expression. As a side note: thinking of -5 as 0 - 5 isn't wrong and you can still get the idea of a direction by thinking of subtraction as drawing an arrow on the number line. For any subtraction "n - m" draw the arrow from m to n. So for 5 - 0 you draw an arrow from 0 to 5 which is an arrow pointing to the right. For 0 - 5 you'd do the opposite, draw the arrow from 5 to 0 which is an arrow to the left. And 0 - (-5) is an arrow from -5 to 0 which is again an arrow pointing right. So either way you still end up with the idea of negative values changing the direction but personally I find it more intuitive to think of multiplication by -1 as "flipping" the direction.
@LazyDevs9 ай бұрын
No need to apologize. On the contrary, thank you for the clarification. This helps!