MATH & COMPUTER SCIENCE
Base Calculator
Convert an integer between common number bases such as binary, octal, decimal and hexadecimal.
How number bases work
A positional number system assigns each digit a place value based on powers of its base. Decimal is base 10, binary is base 2, octal is base 8 and hexadecimal is base 16.
Worked example
Binary 1011 equals 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11 in decimal. Decimal 255 is FF in hexadecimal and 11111111 in binary.
Where base conversion is used
Binary is fundamental to digital systems, hexadecimal is common in programming and memory representation, and other bases are useful in mathematics and computer science. Base conversion changes how an integer is written; it does not change the underlying quantity.
How to use this base calculator
- Enter a whole number in the Integer field. The input is interpreted as a decimal integer.
- Enter a target base from 2 to 36. Use 2 for binary, 8 for octal, 10 for decimal, or 16 for hexadecimal.
- Select Convert. The result is displayed using the digit symbols supported by JavaScript, with alphabetic digits shown in uppercase.
This tool converts from decimal to the selected target base. It does not accept a binary, octal or hexadecimal string as the starting input; convert such a value to decimal first, or use a dedicated source-base converter.
Formula: place values in a positional number system
For base b, a numeral with digits dn through d0 represents dnbn + … + d1b + d0. Each digit must be less than the base. In base 2, digits are only 0 and 1; in base 16, digits 0–9 and A–F represent values zero through fifteen.
Worked conversion: decimal 45 to binary
Repeatedly divide 45 by 2 and record each remainder: 45 ÷ 2 = 22 remainder 1; 22 ÷ 2 = 11 remainder 0; 11 ÷ 2 = 5 remainder 1; 5 ÷ 2 = 2 remainder 1; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1. Read the remainders from bottom to top: 101101. Check: 32 + 8 + 4 + 1 = 45.
Worked conversion: decimal 255 to hexadecimal
255 = 15 × 16 + 15. The digit value 15 is written as F in hexadecimal, so 25510 = FF16. In binary, the same value is 111111112.
Important limits and common mistakes
- Input is decimal: entering 101 means decimal one hundred and one, not binary 101.
- Integers only: fractions and decimal points are not supported by this integer converter.
- Safe integer range: very large integers may exceed JavaScript's exact integer range; this calculator rejects values outside the safe-integer range.
- Base range: only whole-number target bases from 2 to 36 are accepted.
- Leading zeros: conversion returns a normalized representation and does not preserve leading zeros.
FAQ
Why does hexadecimal use A–F? These symbols represent digit values 10–15, allowing sixteen distinct digit values in base 16.
Which bases are supported? Integer conversion supports target bases from 2 through 36, including binary, octal, decimal and hexadecimal.
Does entering 101 convert binary 101? No. The input field is a decimal integer, so 101 is interpreted as decimal one hundred and one. Binary 101 equals decimal 5.
Why is the result different from the input? The quantity stays the same but its written representation changes according to the target base.
Can I convert negative integers? Yes, the calculator supports safe negative integers and applies the selected base to their magnitude with a leading minus sign.