Skip to main content
Viva Calculator

Binary Calculator

Convert whole numbers across bases 2, 8, 10, and 16

Convert

Method and source check

Last checked:

Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.

Method

Validate every digit against the selected base, parse the signed integer with BigInt, then format it in bases 2, 8, 10, and 16.

value = Σ digit × base^place

Variables and units

base
2, 8, 10, or 16
value
whole integer represented by all input digits

Worked example

1011 in base 2 equals 11 in base 10 and B in base 16.

Limitations

No rounding; validated integer strings are converted with BigInt and formatted exactly in bases 2, 8, 10, and 16, subject to available runtime memory.

  • Whole numbers only; input digits must match the selected base. Very long accepted inputs may consume time or memory.
  • 1011₂ → 11₁₀
  • 102₂ and oops₁₀ rejected
  • 9007199254740993₁₀ round trips unchanged

Sources

How to Use

  1. Select the base of the number you are entering.
  2. Enter only digits valid in that base: 0–1 for binary, 0–7 for octal, 0–9 for decimal, or 0–9 and A–F for hexadecimal.
  3. Read the same whole number in all four bases.

Select the base of the number you are entering

Enter only digits valid in that base: 0–1 for binary, 0–7 for octal, 0–9 for decimal, or 0–9 and A–F for hexadecimal. Number systems are methods of representing numbers using different bases. While we commonly use the decimal system (base 10) in everyday life, computers internally use binary (base 2), and programmers often work with octal (base 8) and hexadecimal (base 16) systems.

Each number system uses a specific set of digits and a base value that determines place values. Understanding these systems is essential for computer science, programming, and digital electronics.

Method source: OpenStax, Rice University. https://openstax.org/books/contemporary-mathematics/pages/4-3-converting-with-base-systems

Types of Number Systems

SystemBaseDigits UsedCommon Use
Binary20, 1Computer internal representation
Octal80-7Unix file permissions, legacy systems
Decimal100-9Everyday mathematics
Hexadecimal160-9, A-FColors, memory addresses, debugging

How Number System Conversion Works

Converting between number systems involves understanding place values. In binary (base 2), each position represents a power of 2. In hexadecimal (base 16), each position represents a power of 16.

For example, the binary number 1011 equals: (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11 in decimal.

Worked example

Binary 1010, decimal 10, and hexadecimal A represent the same whole number. Select the input base before comparing the four representations.

Frequently Asked Questions

What is binary and why do computers use it?
Binary is a base-2 number system using only 0 and 1. Computers use binary because electronic circuits have two stable states (on/off, high voltage/low voltage), making binary the natural choice for digital systems.
How do I convert decimal to binary manually?
Divide the decimal number by 2 repeatedly, recording the remainder each time. Read the remainders from bottom to top to get the binary equivalent. For example, 13 ÷ 2 = 6 R1, 6 ÷ 2 = 3 R0, 3 ÷ 2 = 1 R1, 1 ÷ 2 = 0 R1, giving 1101 in binary.
Why is hexadecimal useful in programming?
Hexadecimal is compact and easier to read than binary while maintaining a direct relationship with binary (each hex digit represents exactly 4 binary digits). It's commonly used for memory addresses, color codes, and debugging.
What's the difference between octal and hexadecimal?
Octal uses base 8 (digits 0-7) where each digit represents 3 binary digits, while hexadecimal uses base 16 (digits 0-9, A-F) where each digit represents 4 binary digits. Hexadecimal is more commonly used today.