Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 4
    +1. I think this is a pretty good guided tour around the evolution of these operators.
    – Steve
    Commented Oct 1, 2019 at 19:37
  • BTW, sign/magnitude and one's complement machines also need separate bitwise vs. logical negation, even if the input is already booleanized. ~0 (all bits set) is one's complement negative zero (or a trap representation). Sign/magnitude ~0 is a negative number with maximum magnitude. Commented Oct 3, 2019 at 10:51
  • @PeterCordes You’re absolutely right. I was just focusing on two’s-complement machines because they’re a lot more important. Maybe it’s worth a footnote.
    – Davislor
    Commented Oct 3, 2019 at 13:05
  • I think my comment is sufficient, but yeah, maybe a parenthetical (doesn't work for 1's complement or sign/magnitude either) would be a good edit. Commented Oct 3, 2019 at 13:15
  • According to K&R explanations, the main purpose of short circuit is not to make it faster, but to allow conditions that avoid hard failures (e.g: if (i!=0 && k/i>x) will never lead to a division by 0, which would not be guaranteed without short circuits; same for p==NULL || *p=='\0'). Then, C before 1978 K&R was not yet C but a development version of it, isn’t it? Finally, I do not get from your explanations why the designers dit chose ! an not ~~ (which was in fact the question that we had to answer). You just say they picked the first. But why?
    – Christophe
    Commented Feb 28, 2020 at 0:15