Understanding and Using Number Base Conversions
Convert between decimal, binary, octal, and hexadecimal with practical programming applications.
Key Takeaways
- A number base (radix) determines how many unique digits are used.
- Computers process information as binary — sequences of 0s and 1s representing on/off states.
- Hexadecimal provides a compact way to represent binary data — each hex digit maps to exactly 4 binary digits.
- Octal's main modern use is Unix file permissions.
- To convert decimal to any base: repeatedly divide by the base and collect remainders in reverse.
Percentage Calculator
Calculate percentages, increases, decreases, and ratios
Number Systems Explained
A number base (radix) determines how many unique digits are used. Decimal (base 10) uses 0-9. Binary (base 2) uses 0-1. Octal (base 8) uses 0-7. Hexadecimal (base 16) uses 0-9 and A-F. Each system exists because it's useful in specific contexts — binary for hardware, hex for compact binary representation, octal for Unix permissions.
Binary: The Hardware Language
Computers process information as binary — sequences of 0s and 1s representing on/off states. Understanding binary is essential for bit manipulation, network masks, and low-level programming. The binary number 10110 equals 22 in decimal: (1×16) + (0×8) + (1×4) + (1×2) + (0×1). Each position represents a power of 2.
Hexadecimal: Compact Binary
Hexadecimal provides a compact way to represent binary data — each hex digit maps to exactly 4 binary digits. The byte value 11111111 (binary) = FF (hex) = 255 (decimal). Hex is ubiquitous in color codes (#FF6B35), memory addresses (0x7FFF0000), and MAC addresses (AA:BB:CC:DD:EE:FF). It's easier to read and write than long binary strings.
Octal: Unix Permissions
Octal's main modern use is Unix file permissions. The permission 755 means owner=rwx (7=4+2+1), group=r-x (5=4+0+1), others=r-x (5=4+0+1). Each octal digit represents exactly 3 binary bits, mapping perfectly to the read-write-execute permission model.
Conversion Techniques
To convert decimal to any base: repeatedly divide by the base and collect remainders in reverse. To convert any base to decimal: multiply each digit by the base raised to its position power and sum. Between binary and hex: group binary digits in fours from right, convert each group. Between binary and octal: group in threes. Programming languages provide built-in functions: Python's bin(), oct(), hex(), and int() with base parameter.
Verwandte Tools
Verwandte Anleitungen
How to Use Scientific Notation and Number Formatting
Scientific notation makes very large and very small numbers manageable. This guide covers notation systems, significant figures, and formatting conventions used in science, engineering, and finance.
Unit Conversion Best Practices for Developers
Incorrect unit conversions have caused spacecraft crashes and medical errors. This guide covers best practices for implementing unit conversions in software, including precision handling and common pitfalls.
Percentage Calculations: Common Formulas and Pitfalls
Percentage calculations appear simple but hide common errors, especially around percentage change, percentage points, and compound percentages. This guide clarifies the math behind everyday percentage problems.
Matrix Operations: A Visual Guide for Developers
Matrices are fundamental to graphics, machine learning, and data processing. This guide explains matrix addition, multiplication, transposition, and inversion with visual examples and practical applications.
Troubleshooting Floating-Point Precision Errors
Floating-point arithmetic produces surprising results that can cause bugs in financial calculations, comparisons, and cumulative operations. This guide explains why these errors occur and how to handle them.