@lore Zallen {0,1}.
Seemingly the negation of X and 1. Negation of X being the bit flip of the binary number. So it's going to be swapping to truth value and adding a 1 to it. It could return the same value or probably cause a compiler error. The bool is not bitwise but the operation occurs outside the bool.

It's not comfortable code to look at.

@AmpBenzScientist it's not really adding a 1 because that's an AND, not an OR. and in C/C++, bool is just an integer type. it's considered true if nonzero.

Follow

@lore That's likely where I got confused. In Mathematics the tilde (~) is used to negate. For a Boolean value we used T or F instead of 0 and 1. This is because they are True or False and the 0 or 1 could imply that they are integers. While {0,1} are a subset of Integers, they are merely place holders and not subject to operations.

Perhaps what confused me the most was that there was no mod 2 operation visible. I do assume at first that it would return two values but I couldn't understand why it would do so.
(See nearly every example of C with return 0 ie it worked or the other numbers from where code failed.)

The more I looked at it, it started to appear to be a weird Comp Sci thing and it did turn into more weird Comp Sci things. I've used C for a while and Cpp until around 4 years ago when Cpp++ really made me hate it.

I'm stumped, it seemingly returns bit flipped X (or negation X) And 1. I don't see what it does and I'm not cheating and compiling it. Assuming that X has the value of 0 it could bit flip to 1 and that's what the result is but I really don't get what the & 1 is doing. Very humbling.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.