The Binary Number System
Binary is base-2: every digit is either 0 or 1. Each position represents a power of 2. Reading from right to left: the rightmost bit is 2⁰ (1), next is 2¹ (2), then 2² (4), 2³ (8), and so on. Add the powers where the bit is 1:
1010 1100 (binary) = 128 + 32 + 8 + 4 = 172 (decimal)
0100 0001 (binary) = 64 + 1 = 65 = 'A' in ASCII
Bits, Bytes, and Words
- Bit: One binary digit (0 or 1). The smallest unit of data.
- Byte: 8 bits. Can represent 256 values (0–255). One ASCII character = one byte.
- Word: Architecture-dependent — 16 bits (2 bytes), 32 bits (4 bytes), or 64 bits (8 bytes).
- MSB (Most Significant Bit): The leftmost bit in a byte (value 128).
- LSB (Least Significant Bit): The rightmost bit in a byte (value 1).
Text as Binary
Every character you type is stored as a binary number. ASCII maps 128 characters to 7-bit values. UTF-8 extends this to variable-length encoding for all of Unicode:
'A' = 65 = 01000001
'B' = 66 = 01000010
'a' = 97 = 01100001
'0' = 48 = 00110000
' ' = 32 = 00100000
Bitwise Operations
Working directly with bits is essential in systems programming, cryptography, and performance optimization:
AND: 1010 & 1100 = 1000 (both bits 1)
OR: 1010 | 1100 = 1110 (either bit 1)
XOR: 1010 ^ 1100 = 0110 (bits differ)
NOT: ~1010 = 0101 (flip all bits)
SHL: 1010 << 1 = 10100 (left shift = multiply by 2)
SHR: 1010 >> 1 = 0101 (right shift = divide by 2)
Converting Between Bases
// JavaScript
(172).toString(2) // "10101100" — decimal → binary
(172).toString(16) // "ac" — decimal → hex
parseInt("10101100", 2) // 172 — binary → decimal
parseInt("AC", 16) // 172 — hex → decimal
View & Convert Binary Instantly
Use ToolsVito's Binary Viewer to convert any text or number to binary bits and decode binary back. View as grouped 8-bit bytes or as a raw stream. All conversion happens in your browser.