News for hackers. Stuff that matters.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by threatofrain on Friday January 05, 2024 @06:19PM (#38886412)
I've never heard of saturation arithmetic and now it all makes sense. Otherwise I thought it was more common to think of XOR as boolean addition, and OR would be represented as xy + x + y.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by layer8 on Friday January 05, 2024 @06:32PM (#38886549)
Yes, true and false with AND and XOR form a mathematical ring [0]. Still, OR is also an additive operation. IMO one could give OR and XOR the same precedence.

On the other hand, there is no strict need to have a dedicated boolean XOR operator, as it works the same as = (equals).

[0] https://en.wikipedia.org/wiki/Ring_(mathematics)

Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by orlp on Saturday January 06, 2024 @06:30AM (#38890539)
More than just a ring, it is the simplest finite field.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by o11c on Friday January 05, 2024 @07:47PM (#38887089)
Saturation is actually the wrong way to think about bools when other operations get involved:

saturate(0 - 1) = 0

bool(0 - 1) = 1

Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by dataflow on Friday January 05, 2024 @10:53PM (#38888230)
Fun (but not particularly useful fact) is you can also represent x OR y as 1 - (1 - x)(1 - y). This shouldn't be too weird since x OR y is equal to NOT ((NOT x) AND (NOT y)).