Number base converter
Math & numbersHow do you convert a number between bases?
Convert whole numbers between binary, octal, decimal, hexadecimal and any base up to 36.
What you enter stays on your device while you use this tool. Opening a shared link sends the settings in its address to HowToolbox to prepare the page.
In hexadecimal
ff
3 digits read in base 10
The same number in other bases
- In binary
- 11111111
- In octal
- 377
- In decimal
- 255
Sponsored Links
Convert whole numbers between binary, octal, decimal, hexadecimal and any base up to 36.
How to use
- Type the number. Digits above 9 are letters: A or a is ten, F is fifteen.
- Choose the base it is written in, then the base to convert to. 10 is the everyday decimal, 2 binary, 8 octal and 16 hexadecimal.
- Copy the result. The same number is also shown in the other common bases.
How it works
A base says how many digits a numbering system has, and each place is worth that many times the one to its right. In decimal the places are ones, tens, hundreds. In binary they are ones, twos, fours, eights. In hexadecimal, which has 16 digits (0–9 and A–F), they are ones, sixteens, 256s and so on. Computers use binary, and hexadecimal is a compact way to write it: one hex digit is exactly four binary digits.
To convert, add up each digit times the value of its place. For example hex FF is 15 × 16 + 15 = 255, which is 11111111 in binary and 377 in octal. Going the other way, divide by the new base again and again and read the remainders backwards (Knuth, The Art of Computer Programming, vol. 2, section 4.1).
This tool works with whole numbers of any size, so a 64-bit or even larger value stays exact, and accepts bases from 2 to 36, where the letters a to z are the digits ten to thirty-five. You can type spaces or underscores to group digits, a minus sign, and the usual 0x, 0b and 0o prefixes. Fractions are not converted.
Worked example
What is hexadecimal 2A in decimal?
- Its digits represent 2 × 16 + 10.
The decimal value is 42.
Sponsored Links
Frequently asked questions
Why do programmers use hexadecimal?
It is a short way to write binary: every hex digit stands for exactly four bits, so a byte is two hex digits, such as FF.
What does the 0x in front of a number mean?
It marks a hexadecimal number in many programming languages. 0b marks binary and 0o octal. You can leave it in or out here.
Why does it say a digit is not valid?
Each base has only as many digits as its number. Base 8 has 0 to 7, so 9 cannot appear, and base 2 only has 0 and 1. Check the base the number is written in.
Does uppercase change a hexadecimal number’s value?
No. A–F and a–f represent the same digits. Uppercase changes only how the result is written.
Are negative values shown in two’s complement?
No. The converter keeps a minus sign. Two’s complement needs a chosen bit width and is not calculated here.
Next you might need
- Base64 encode and decodeEncode text or a file to Base64 and decode it back, right in your browser., private, runs on your deviceText toolsConverterEncoding
- Hash generatorSHA-256, SHA-512, SHA-1 and MD5 hashes of any text, made in your browser., private, runs on your deviceWeb & developerGeneratorEncoding
- Average calculatorMean, median, mode and range of a list of numbers, with the count, sum, smallest and largest., private, runs on your deviceMath & numbersCalculatorStatistics
- Combinations and permutations calculatorExact counts of combinations and permutations, with or without repetition, and the chance of one particular pick., private, runs on your deviceMath & numbersCalculatorStatistics
- Confidence interval calculatorThe confidence interval for a mean or a proportion from a sample, with the margin of error and the method used., private, runs on your deviceMath & numbersCalculatorStatistics
- Fraction calculatorAdd, subtract, multiply and divide fractions and mixed numbers, or turn a decimal into a fraction, with the answer in lowest terms., private, runs on your deviceMath & numbersCalculator
More in Math & numbers
All 24 utilities in Math & numbers- Percentage calculatorPercent of a number, what percent one number is of another, percentage change and difference, and the number before a discount., private, runs on your device
- Area of shapesArea and perimeter of rectangles, circles, triangles and eight more shapes, drawn to scale., private, runs on your device
- GCD and LCM calculatorThe greatest common divisor and the least common multiple of two to ten whole numbers, with the Euclidean steps., private, runs on your device
- Prime number checkerTest any whole number up to 100 digits for primality, with its prime factors and the next and previous prime., private, runs on your device
- Ratio calculatorSimplify a ratio to its lowest terms, or find the missing number in an equal ratio, the rule of three., private, runs on your device
- Sample size calculatorThe number of survey responses you need for a margin of error and confidence level, for any population size., private, runs on your device
Popular now
Sponsored Links
Sponsored Links
Sponsored Links