Binary in Computing

Como Computers Think in 1s e 0s

Understand Binary

Todo photo, video, program, e website ultimately exists as patterns of 1s e 0s. Binary isn't apenas outro number sistema—it's o foundation of todos digital technology. Understanding binary reveals como computers work at their mais fundamental level.

Bits e Bytes

O Bit

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

O Byte

  • 8 bits grouped together
  • Can represent 2⁸ = 256 diferente values (0-255)
  • Padrão unidade for character storage
  • Foundation for larger unidades (KB, MB, GB)

Larger Unidades

UnidadeSizeValues
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

Como Data Is Represented

Text (Characters)

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

Exemplo: '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 cada for Red, Green, Blue)
  • 1920×1080 image ≈ 6.2 million bytes uncompressed

Audio

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

Binary Arithmetic

Addition

Mesmo 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)

Exemplo: 1011 + 1101

  1011
+ 1101
------
 11000

= 11 + 13 = 24 ✓

Logic Gates

Hardware implements binary operations through logic gates:

Basic Gates

GateFunctionTruth
ANDAmbos inputs must be 11 AND 1 = 1
ORAt least one input é 11 OR 0 = 1
NOTInverts inputNOT 1 = 0
XORExatamente one input é 11 XOR 1 = 0
NANDNOT AND1 NAND 1 = 0

Complex operations (addition, comparison) são built from combinations of estes simples gates.

Signed Numbers: Two's Complement

Como computers represent negative numbers:

Method

  1. Invert todos bits
  2. Add 1

Exemplo: -5 in 8-bit

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

Por que Two's Complement?

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

Bitwise Operations in Programming

Programming languages provide operators for bit manipulation:

Comuns Operations

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

Exemplo: Check if number é mesmo

n & 1 == 0 means n é mesmo

(Último bit determines odd/mesmo)

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

  • Todos files são sequences of bytes
  • File type determined by content/structure

Encryption

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

Conclusão

Binary é o language of todos digital systems because electronic components naturally têm two states. Todo piece of digital data—text, images, audio, video, programs—é ultimately represented as patterns of bits. Understanding binary illuminates como computers work: from o logic gates performing operations to o bytes storing characters to o bits flying across networks. While we rarely interact com binary directly, it underlies everything in o digital mundo.

Artigos Relacionados

Binary in Computing: Como Computers Usar 1s e 0s | YounitConverter