Number Base Converter
Binary, octal, decimal and hex, with nothing lost on a 64-bit value.
Convert numbers between binary, octal, decimal, hexadecimal and any base up to 36, using arbitrary precision so 64-bit values keep every digit.
- Bits needed
- 8
- Fits in
- 8 bits
- Digits, decimal
- 3
- As a Unicode code point
- U+00FF ÿ
Why BigInt
A 64-bit value such as 0xFFFFFFFFFFFFFFFF is ordinary in a hex dump and cannot be held in a JavaScript number: parseInt returns 18446744073709552000, which is wrong in its last four digits and converts back to a different hex string. Everything here goes through arbitrary-precision integers, so nothing is lost however long the value is.
Base 36 is where digits run out: ten numerals plus twenty-six letters, and nothing left to borrow. Octal survives mainly because Unix file permissions are three groups of three bits, which is exactly one octal digit each — the reason chmod 755 looks the way it does. Hexadecimal survives because one digit is precisely four bits, so a byte is always two characters and never one and a bit.
How the Number Base Converter works
Every conversion here goes through arbitrary-precision integers rather than ordinary numbers, because a 64-bit value is perfectly common in a hex dump and cannot be held in a floating point number without losing its last few digits — which is precisely the case a converter exists to be trusted with.
Also known as: binary to decimal converter · hex to decimal converter · decimal to binary converter · binary hex octal converter · base 36 converter
Frequently asked questions
Why do other converters get large hex values wrong?
Because they use ordinary JavaScript numbers, which are floating point and hold about 15 significant decimal digits. Parse 0xFFFFFFFFFFFFFFFF that way and you get 18446744073709552000, which is wrong in its last four digits and converts back to a different hex string entirely. Nothing is reported as an error; the answer is simply wrong. This one uses arbitrary precision, so a value of any length keeps every digit.
Why is hexadecimal used so much in computing?
Because one hex digit is exactly four bits, so a byte is always two characters and never one and a bit. That makes a hex dump line up in columns and makes it trivial to read individual bits out of a value. Decimal has no such relationship with binary, which is why a memory address in decimal is unreadable and the same address in hex is not.
Why does octal still exist?
Mainly because Unix file permissions are three groups of three bits, and three bits is exactly one octal digit. That is the entire reason chmod 755 looks the way it does. Outside permissions and a few file formats it has largely been replaced by hexadecimal, which lines up with bytes rather than with three-bit groups.
What is two's complement?
How negative numbers are actually stored. Rather than reserving a sign bit and negating, the value is subtracted from two to the power of the width, so minus one in eight bits is 0xFF and in 32 bits is 0xFFFFFFFF. It has the useful property that addition and subtraction work identically on signed and unsigned values, which is why every current processor uses it. It is shown here for each common width when the value is negative.
Why does base 36 stop there?
Because digits run out. Ten numerals plus twenty-six letters is thirty-six symbols and there is nothing conventional left to borrow, so 36 is the highest base that can be written with one character per digit using the usual alphabet. Base 64 exists but needs a defined symbol set including punctuation, and encodes bytes rather than numbers.
Related calculators
Chmod Calculator
Including the fourth digit that most calculators leave out.
OpenBase64 Encoder and Decoder
Handles emoji and every other script, which most converters cannot.
OpenSubnet Calculator
Including the /31 and /32 that most calculators get wrong.
Open