Binary in Computing

How Computers Think in 1s and 0s

Understand Binary

Every photo, video, program, and website ultimately exists as patterns of 1s and 0s. Binary isn't just another number system—it's the foundation of all digital technology. Understanding binary reveals how computers work at their most fundamental level.

Bits and Bytes

The Bit

  • Smallest unit of data
  • Single binary digit: 0 or 1
  • "Binary digit" shortened to "bit"
  • Can represent two states (yes/no, on/off, true/false)

The Byte

  • 8 bits grouped together
  • Can represent 2⁸ = 256 different values (0-255)
  • Standard unit for character storage
  • Foundation for larger units (KB, MB, GB)

Larger Units

UnitSizeValues
Byte8 bits256
Word (16-bit)2 bytes65,536
Double word (32-bit)4 bytes~4.3 billion
Quad word (64-bit)8 bytes~18.4 quintillion

How Data Is Represented

Text (Characters)

  • ASCII: 7 bits, 128 characters
  • Extended ASCII: 8 bits, 256 characters
  • Unicode (UTF-8): Variable length, millions of characters

Example: 'A' = 01000001 (65 in decimal)

Numbers

  • Integers: Direct binary representation
  • Negative numbers: Two's complement
  • Decimals: Floating-point (IEEE 754)

Images

  • Pixels represented as numbers
  • RGB: 3 bytes per pixel (8 bits each for Red, Green, Blue)
  • 1920×1080 image ≈ 6.2 million bytes uncompressed

Audio

  • Sound waves sampled as numbers
  • CD quality: 16-bit samples, 44,100 times per second

Binary Arithmetic

Addition

Same as decimal, but carry at 2:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 0 = 1
  • 1 + 1 = 10 (0, carry 1)
  • 1 + 1 + 1 = 11 (1, carry 1)

Example: 1011 + 1101

  1011
+ 1101
------
 11000

= 11 + 13 = 24 ✓

Logic Gates

Hardware implements binary operations through logic gates:

Basic Gates

GateFunctionTruth
ANDBoth inputs must be 11 AND 1 = 1
ORAt least one input is 11 OR 0 = 1
NOTInverts inputNOT 1 = 0
XORExactly one input is 11 XOR 1 = 0
NANDNOT AND1 NAND 1 = 0

Complex operations (addition, comparison) are built from combinations of these simple gates.

Signed Numbers: Two's Complement

How computers represent negative numbers:

Method

  1. Invert all bits
  2. Add 1

Example: -5 in 8-bit

  • 5 = 00000101
  • Invert: 11111010
  • Add 1: 11111011
  • -5 = 11111011

Why Two's Complement?

  • Addition works naturally (no special cases)
  • One representation for zero
  • Easy to implement in hardware

Bitwise Operations in Programming

Programming languages provide operators for bit manipulation:

Common Operations

  • AND (&): Mask certain bits
  • OR (|): Set certain bits
  • XOR (^): Toggle bits, encryption
  • NOT (~): Invert all bits
  • Left shift (<<): Multiply by 2ⁿ
  • Right shift (>>): Divide by 2ⁿ

Example: Check if number is even

n & 1 == 0 means n is even

(Last bit determines odd/even)

Binary in Modern Computing

Memory Addresses

  • 32-bit: Can address 2³² = 4 GB
  • 64-bit: Can address 2⁶⁴ = 16 exabytes

Network Addresses

  • IPv4: 32 bits (e.g., 192.168.1.1)
  • IPv6: 128 bits

File Sizes

  • All files are sequences of bytes
  • File type determined by content/structure

Encryption

  • AES uses 128, 192, or 256-bit keys
  • SHA-256 produces 256-bit hashes

Conclusion

Binary is the language of all digital systems because electronic components naturally have two states. Every piece of digital data—text, images, audio, video, programs—is ultimately represented as patterns of bits. Understanding binary illuminates how computers work: from the logic gates performing operations to the bytes storing characters to the bits flying across networks. While we rarely interact with binary directly, it underlies everything in the digital world.

Related Articles

Binary in Computing: How Computers Use 1s and 0s | YounitConverter