Binary, Decimal, e Hexadecimal
Understanding Number Bases
Compare Number SystemsComputers speak binary, humans think in decimal, e programmers often use hexadecimal as a convenient middle ground. Understanding estes three number systems é fundamental to computing, programming, e digital literacy.
Decimal (Base-10)
O sistema humans use todo day.
Como It Works
- 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Cada position é a power of 10
- Position values: ...1000, 100, 10, 1
Exemplo: 3,452
- 3 × 1000 = 3000
- 4 × 100 = 400
- 5 × 10 = 50
- 2 × 1 = 2
- Total = 3452
Por que Base-10?
Likely from counting on 10 fingers. Deeply ingrained in human culture e language.
Binary (Base-2)
O language of computers.
Como It Works
- 2 symbols: 0 e 1
- Cada position é a power of 2
- Position values: ...128, 64, 32, 16, 8, 4, 2, 1
Exemplo: 10110101 (binary)
| Position | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Digit | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| Valor | 128 | 0 | 32 | 16 | 0 | 4 | 0 | 1 |
Total = 128 + 32 + 16 + 4 + 1 = 181 (decimal)
Por que Computers Usar Binary
- Electronic switches têm two states: on/off
- Tensão levels: high/low
- Simples logic circuits
- Error-resistant (clear distinction entre states)
Hexadecimal (Base-16)
A human-friendly way to represent binary data.
Como It Works
- 16 symbols: 0-9 e A-F
- A=10, B=11, C=12, D=13, E=14, F=15
- Cada position é a power of 16
- Position values: ...4096, 256, 16, 1
Exemplo: 2A9F (hexadecimal)
- 2 × 4096 = 8192
- A (10) × 256 = 2560
- 9 × 16 = 144
- F (15) × 1 = 15
- Total = 10,911 (decimal)
Por que Hexadecimal?
- Cada hex digit = exatamente 4 binary digits
- Much shorter than binary (FF vs 11111111)
- Fácil to converter to/from binary
- Comuns in programming, colors, memory addresses
Comparison Table
| Decimal | Binary | Hexadecimal |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 5 | 0101 | 5 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
| 100 | 1100100 | 64 |
| 255 | 11111111 | FF |
| 256 | 100000000 | 100 |
| 1000 | 1111101000 | 3E8 |
Quando Cada Sistema Is Usado
Decimal
- Cotidiano counting e arithmetic
- Financial calculations
- User interfaces (o que humans see)
Binary
- Computer hardware operations
- Network addresses (IPv4, subnet masks)
- Bitwise operations in programming
- Understanding computer fundamentals
Hexadecimal
- Color codes (web design): #FF5733
- Memory addresses in debugging
- MAC addresses: 00:1A:2B:3C:4D:5E
- Character encodings (Unicode)
- Cryptography e hashes
Notation Conventions
Como to identify qual base a number é in:
Prefixes
- 0b ou 0B: Binary (0b1010)
- 0x ou 0X: Hexadecimal (0xFF)
- 0o ou 0: Octal (0o17 ou 017)
- No prefix: Usually decimal
Suffixes
- ₂: Binary (1010₂)
- ₁₀: Decimal (10₁₀)
- ₁₆ ou h: Hexadecimal (FFh ou FF₁₆)
Comuns Values to Memorize
| Concept | Decimal | Binary | Hex |
|---|---|---|---|
| One byte (max) | 255 | 11111111 | FF |
| One byte + 1 | 256 | 100000000 | 100 |
| Two bytes (max) | 65,535 | 16 ones | FFFF |
| Powers of 2 | 1,2,4,8,16,32,64,128,256,512,1024 | 1,10,100... | 1,2,4,8,10,20,40,80,100... |
Conclusão
Understanding binary, decimal, e hexadecimal é essential for anyone trabalhando com computers. Decimal é natural for humans, binary é natural for computers, e hexadecimal bridges o two—making binary data readable while remaining compact. O key insight é esse estes são apenas diferente ways of representing o mesmo values, cada com their own advantages: decimal for human calculation, binary for hardware efficiency, e hexadecimal for programmer convenience.