News for hackers. Stuff that matters.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by threatofrain on Friday January 05, 2024 @05:56PM (#38886194)
Isn't it x ^ y which is like x + y?
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by pcwalton on Friday January 05, 2024 @06:06PM (#38886286)
Yeah, | is technically x + y + x*y over GF(2) (this is the Boolean ring to Boolean algebra relation [1]). The GP is still a good way to remember the precedence though.

[1]: https://en.wikipedia.org/wiki/Boolean_ring#Relation_to_Boole...

Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by o11c on Friday January 05, 2024 @07:45PM (#38887071)
^ is like + when operating over bits, since (bit)2 == 0

| is like + when operating over bools, since (bool)2 == 1

Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by pvtmert on Friday January 05, 2024 @07:11PM (#38886841)
xor is more like a substraction...
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by trealira on Saturday January 06, 2024 @03:35AM (#38889677)
Yeah. To sum two bits x and y, the immediate sum is x XOR y, and the carry is x AND y. That's how a simple half-adder circuit can be made.