2’s Complement and Binary Operations

Why bits?

  • Easy to store with bitsable elements
  • Reliably transmitted on noisy and inaccurate wires Screenshot 2025-08-25 at 13.30.19

Data Representations in C

C Data Type32-bit64-bitx86-64
char111
short222
int444
long488
float444
double888
long double__10/16
pointer488

Boolean Operations

Screenshot 2025-08-25 at 13.59.18

In C

c = a & b; // and
c = a | b; // or
c = a ^ b; // xor
c = ~a; // complement

Representing and Manipulating Sets

  • 01101001: {1, 2, 4, 7}

Shift Operations