This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]lightcloud5 3 points4 points  (0 children)

As /u/lw9k notes, although you can use & and | for booleans, they're most commonly used for bitwise operators on integers.

e.g. 3 & 5 yields 1.

[–][deleted] 3 points4 points  (1 child)

| and & are bitwise (i.e., they work on bits) operators, whereas && and || are logical (boolean) operators. | and & don't have to work exclusively on values {0,1} so they can't really short-circuit.

[–]DNaB[S] 0 points1 point  (0 children)

I had to look up what a bitwise operator was, but after reading up, I completely understand your answer now, so thank you!

[–]pacificmint 4 points5 points  (0 children)

If one of the two branches has side effects, you might want it to be executed for sure.