How to use the The Developer's Guide to Bases
Computers process information in Binary (Base 2), using switches that are either ON (1) or OFF (0). However, binary is verbose and hard for humans to read. Programmers use Hexadecimal (Base 16) as a compact shorthand to represent binary data, where one hex digit represents exactly four bits (a nibble).
🎨 Why Hex for Colors?
A hex color like #FF5733 uses 2 digits per channel
(Red, Green, Blue). FF in hex is 255 in decimal, meaning 100%
intensity. This allows for 16.7 million unique color combinations
(256 x 256 x 256) in a compact 6-character string.
⚠️ Signed vs. Unsigned
In many programming languages, integers have a size limit. An 8-bit Unsigned Integer can hold 0 to 255. A Signed Integer uses one bit for the sign (+/-), reducing the range to -128 to 127. Overflowing this range causes "wraparound" bugs!
The Formula
Bitwise Operations Guide
AND (&)
Result is 1 only if BOTH bits are 1. Used for masking
(clearing specific bits).
1010 & 1100 = 1000
OR (|)
Result is 1 if AT LEAST one bit is 1. Used for setting
specific bits.
1010 | 1100 = 1110
XOR (^)
Result is 1 if bits are DIFFERENT. Used for toggling
bits and cryptography.
1010 ^ 1100 = 0110
NOT (~)
Inverts all bits (0 becomes 1, 1 becomes 0). Also known as One's Complement.
Data Sizes Reference
| Name | Bits | Range (Unsigned) |
|---|---|---|
| Nibble | 4 | 0 - 15 |
| Byte / Octet | 8 | 0 - 255 |
| Word (16-bit) | 16 | 0 - 65,535 |
| DWord (32-bit) | 32 | 0 - 4.29 Billion |
| QWord (64-bit) | 64 | 0 - 1.84 × 10¹⁹ |