Quick actions

cmd+k|ctrl+k

Navigation

Languages

Bit operators / ~ - bitwise NOT (unary complement) / Essential C++

Snippet info

Language

Cpp

Visibility

public

Author

kkowalczyk

Created

2019-03-27T06:44:21Z

Updated

2019-03-27T06:44:21Z

#include <iostream>

int main(int argc, char **argv) {
    unsigned char a = 234;  // 1110 1010b  (0xEA)
    unsigned char b = ~a;   // 0001 0101b  (0x15)
    
    std::cout << "a = " << static_cast<int>(a) <<
             ", b = " << static_cast<int>(b) << std::endl;
}
INFO