I am studying bitwise operations in bash and understand all the other operations, but this one. It will be a great help if someone can explain (with examples) what the negation (~) operator does in bitwise operations. Couldn't understand from what I read here and elsewhere. TIA!

  • 2
    Related: unix.stackexchange.com/q/75196/237982 – jesse_b Jul 29 at 17:40
  • 1
    Turns out needed to think two's complement to understand it. thanks. seems obvious now – computronium Jul 29 at 17:58
  • actually, bitwise negation has nothing to do with two's complement ... it is the interpretation of the result that could be influenced by two's complement – jsotola Jul 30 at 1:23
  • @jsotola could you please elaborate? – computronium Jul 30 at 8:07

Browse other questions tagged or ask your own question.