3 ms·
Isn't it x ^ y which is like x + y?
by threatofrain 3y ago
Isn't it x ^ y which is like x + y?
- pcwalton 3y agoYeah, | 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_Boolean_algebras https://en.wikipedia.org/wiki/Boolean_ring#Relation_to_Boole...
- pvtmert 3y agoxor is more like a substraction...
- o11c 3y ago^ is like + when operating over bits, since (bit)2 == 0 | is like + when operating over bools, since (bool)2 == 1
- trealira 3y agoYeah. 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.