Understanding Number Systems
A number system defines how numerical values are written using a particular base.
The four number systems most commonly encountered in introductory computing and digital electronics are binary, octal, decimal and hexadecimal.
Each position in a number represents a power of the selected base.
For example, decimal 245 means:
The same place-value principle applies to other bases, but with different powers and allowed digits.
| Number System | Base | Allowed Digits |
|---|---|---|
| Binary | 2 | 0–1 |
| Octal | 8 | 0–7 |
| Decimal | 10 | 0–9 |
| Hexadecimal | 16 | 0–9, A–F |
A hexadecimal digit from A through F represents a value from 10 through 15.
How to Convert Binary to Decimal
Binary is a base-2 system. Each position represents a power of two.
Consider: 101101₂
Starting from the rightmost digit, the positional values are:
| Bit | Place Value | Contribution |
|---|---|---|
| 1 | 2⁵ = 32 | 32 |
| 0 | 2⁴ = 16 | 0 |
| 1 | 2³ = 8 | 8 |
| 1 | 2² = 4 | 4 |
| 0 | 2¹ = 2 | 0 |
| 1 | 2⁰ = 1 | 1 |
Add the contributions: 32 + 8 + 4 + 1 = 45
Therefore: 101101₂ = 45₁₀
Binary-to-decimal conversion is an application of ordinary positional notation.
How to Convert Decimal to Binary
A common method is repeated division by two.
Convert decimal 45:
| Division | Quotient | Remainder |
|---|---|---|
| 45 ÷ 2 | 22 | 1 |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Read the remainders from bottom to top: 101101
Therefore: 45₁₀ = 101101₂
The same repeated-division idea can be used to convert nonnegative integers into other bases by dividing by the target base.
Binary to Octal Conversion
Octal is base 8. Because 8 equals 2³, each octal digit corresponds to exactly three binary bits.
Convert: 101101₂
Group from the right: 101 101
Each group equals decimal 5.
Therefore: 101101₂ = 55₈
If the number of bits is not divisible by three, add leading zeros on the left for grouping purposes. These added zeros do not change the numeric value.
Binary to Hexadecimal Conversion
Hexadecimal is base 16. Because 16 equals 2⁴, one hexadecimal digit represents four binary bits.
Convert: 101101₂
Pad on the left: 0010 1101
The first group: 0010 = 2
The second group: 1101 = 13 = D
Therefore: 101101₂ = 2D₁₆
Grouping bits directly is usually quicker than converting through decimal.
Hexadecimal to Decimal Conversion
Convert hexadecimal 2F to decimal.
Hexadecimal F represents decimal 15.
Use base-16 place values:
Therefore: 2F₁₆ = 47₁₀
This method works for any valid hexadecimal integer.
Number System Comparison Example
Decimal 45 can be written in several ways:
| Number System | Representation |
|---|---|
| Binary | 101101 |
| Octal | 55 |
| Decimal | 45 |
| Hexadecimal | 2D |
All four representations describe the same numerical quantity. Only the base and the symbols used to write it differ.
Where Are Number Systems Used?
Binary in Digital Circuits
Digital circuits operate using discrete logical states commonly represented as 0 and 1.
Hexadecimal in Programming
Hexadecimal provides a compact way to display binary values. A byte can be represented using two hexadecimal digits, making it useful for inspecting memory, bit masks and binary data.
Octal in Computing
Octal appears in some computing conventions, such as Unix-style file permission notation.
Decimal for Human Input
Decimal is the familiar number system used for everyday numeric input and output.
Understanding how these bases relate is useful when working with computer architecture, digital electronics and programming.
Common Number Conversion Mistakes
Using invalid digits: Binary accepts only 0 and 1. Octal accepts only 0 through 7.
Grouping bits from the wrong side: For converting the integer part of binary to octal or hexadecimal, group bits starting from the right.
Confusing hexadecimal letters with decimal digits: A equals 10, B equals 11, continuing through F equals 15.
Losing precision with large integers: JavaScript's Number type cannot represent every large integer exactly. Use exact integer arithmetic when converting large values.
Confusing signed values with two's complement: A leading minus sign is not the same thing as a fixed-width two's-complement binary encoding.
Frequently Asked Questions
How do I convert binary to decimal?
Multiply each bit by its corresponding power of two and add the contributions.
How do I convert decimal to binary?
Repeatedly divide the number by two, record the remainders and read them in reverse order.
Why is hexadecimal used in computers?
One hexadecimal digit corresponds to four binary bits, providing a compact and readable representation of binary values.
Can this converter handle large integers?
The implementation supports large integer values using exact BigInt arithmetic, subject to reasonable input length limits to ensure fast client responsiveness.
Does this converter support fractional numbers?
This version focuses on integer conversions. It does not silently round decimal fractions or pretend to support fractional base conversion. For floating-point representations, use our IEEE 754 Converter.
Related Educational Tools
Explore companion calculators and converters for digital logic design, computer architecture, and number systems.
Gray Code Converter
Convert between binary and binary reflected Gray code with bit-by-bit XOR steps, rules, and reference tables.
IEEE 754 Floating-Point Converter
Explore 32-bit single and 64-bit double precision representations with sign, exponent, and fraction bit fields.
Karnaugh Map Solver
Simplify 2–5 variable Boolean logic functions with step-by-step visual K-Maps, SOP/POS forms, and circuit diagrams.
