Confirmed!

I nearly reported this as spam.
I thought about adding a few sentences and then the links, but I was afraid that would look exactly like the commonly reported spam.
I'm confused as to what exactly this is supposed to be confirming or proving.
((8 << 2) & (2 >> 8) ^ (4 * 4) - ~(8 - 1) - 24)

evaluates to 0
Well, after looking at this, I would say it's more of a matter of opinion on what the order of operations are. We can take that complicated equation and boil it down to
32&0^16-~7-24

I don't think there is a standard order to follow. I think python chooses to follow through in a way where the mathematical answer is 0.

This output is 0 on my computer using C++ also. So why was this a huge debate?
Of course the order is well-defined.
http://cs.smu.ca/~porter/csc/ref/cpp_operators.html

~, -, &, ^. So 32&0^16-~7-24 == (32&0)^((16-(~7))-24) == 0^((16-(-8))-24) == 0^(24-24) == 0^0 == 0.

What isn't defined is what ~7 is. That depends on the type of integer arithmetic used by the computer. Two's complement was assumed here.
I think what he means is the order of operations is not well-defined across languages. C++'s order of operations is, in some instances, arbitrary, and even wrong.

I can never keep them straight across languages, and so I apply parentheses liberally.
IIRC Dennis Ritchie once said that he wished he'd made & have a higher precedence than == so you wouldn't have to use parentheses to test for bit flags. Is that what you mean by wrong?

I think the matrix multiplication notation is wrong. It really ought to be that x * M1 * M2 == f_M2(f_M1(x)). But then, it really ought to be ((x)f_M1)f_M2. Wow, that looks weird.
Yes. [edit]https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Criticism_of_bitwise_and_equality_operators_precedence[/edit]

I'm not sure what you are saying about matrix multiplication. Are you referring to a specific C++ library? And I'm not sure I understand your notation... order matters in matrix multiplication (AB != BA), but it does not matter whether you perform AB first or BC first in ABC. (That is, matrix multiplication is not commutative, but it is associative.)

You know this, so I am confused by what you are trying to say.
Last edited on
Sorry, I should have made it clearer.
In the context of mathematical notation, I'm saying the order of matrix multiplication notation should be inverted, with the transformation that's performed later appearing more to the right, not more to the left, and the same for function application notation.
Ah, I understand, but again, with matrices:

kAB == (kA)B == k(AB)

[edit] Am I being dense here?
Last edited on
Just a little bit.
That multiplication is associative is orthogonal to the matter of the order of notation. What you're saying is correct, but irrelevant.
Uh, I wouldn't say it is orthogonal -- associativity and notation go hand in hand -- unless you are referring to some notation where associativity is indicated in some other way?

I admit I don't know of any other notation for matrices than A to represent something like

┌       ┐
│ 1 2 3 │
│ 4 5 6 │
└       ┘

You can turn vectors and use parentheses (or angle brackets or whatever the mathematician is smoking), but they are just 1D matrices.
I think you mean that "the way associativity is stated goes hand in hand with notation". Yes, "(BA)k == B(Ak)" and "k(AB) == (kA)B" are different strings of symbols that are only meaningful in their respective notations, but they both describe the same property of matrix multiplication.
Topic archived. No new replies allowed.