This lesson says it won’t go into detail about what ~ actually does in a computer but I’m curious if anyone knows of a good article that explains what it does.
Returns the complement of x - the number you get by switching each 1 for a 0 and each 0 for a 1. This is the same as
-x - 1.
To understand the term, ‘complement’, refer to this Wiki…
In particular, “complement of a set A refers to elements not in A.”
Consider the 32-bit pseudo-representation of 0, followed by its complement…
0b00000000000000000000000000000000 0b11111111111111111111111111111111 # ~0
To see how
complement fit into binary, mathematically,
It’s a pretty heady read, but give it your best shot to read it through at some time.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.