I used the bitwise negation operator today, but after searching on the Internet for a long time, I still don’t quite understand what it means, and the results obtained by its meaning are always inaccurate. Talk about your own understanding. // ~(Negative operation) Bit logical NOT operation performs a bitwise negation on the value of the operand
// Computer operations are calculated in the form of complement code~ The symbol is to find the inversion of the complement code of the number The original code of
// Take 6 as an example:
// Original code: Complement code: Complement code: (positive numbers are the same (plus sign bit)) 00000110
// The operation logic of ~ character, first take 6's complement 00000110
// Then Take the negation to get 11111001 (this is a complement) and then find the original code of the complement (the number is the complement of a negative number
) (-7)
//Take -6 as an example:
// Original code: 10000110
// Inverse code: 11111001
// Complement code: 11111010
//~ The operation logic of the character first takes the -6's complement 11111010
// and then Take the opposite of 00000101 (this one's complement representation)
// In seeking its complement form, I get the original code 00000101 (decimal notation means 5) (this is a positive number: the original and negative complements are the same) The above is what I have to understand by myself, it may not be too official, I hope it can be Help everyone understand, and welcome your guidance!