Guide
How binary, octal, decimal and hexadecimal relate
By Logappradeep · ServiceNow developer
A number base, or radix, is how many distinct digits a positional number system uses. We count in base 10 because we have ten fingers, but computers work in base 2 because a transistor is either on or off. Programmers also use base 16 and base 8 because they map neatly onto groups of binary digits. A base converter translates a value between these notations without changing the number itself.
How positional notation works
Each digit's value is the digit multiplied by the base raised to the power of its position, counting from zero on the right. In decimal, 255 means 2 × 10² + 5 × 10¹ + 5 × 10⁰. The same quantity in the other bases is:
- Binary (base 2):
11111111, eight 1 bits, which is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. - Octal (base 8):
377, which is 3 × 64 + 7 × 8 + 7. - Hexadecimal (base 16):
FF, where the digits A to F stand for 10 to 15, so 15 × 16 + 15.
Hexadecimal is popular because each hex digit is exactly four bits, so a byte is always two hex digits. Octal digits are exactly three bits each.
Where you see each base
- Binary: bit flags, bitmasks, network subnet masks (
255.255.255.0is 24 one-bits followed by 8 zero-bits). - Octal: Unix file permissions, where
chmod 755means rwx for the owner (7 = 111) and r-x for group and others (5 = 101). - Hexadecimal: memory addresses, color codes like
#FF8800, byte dumps, hashes and Unicode code points such as U+00E9.
Using the converter
Type a value, choose the base it is written in, and the tool shows it in all four bases at once. Hex output is uppercase. Click any result card to copy it.
Pitfalls
Invalid digits are ignored from that point on. The converter reads digits until it hits one that is not valid for the chosen base, so 12z in decimal is read as 12, and 1012 in binary is read as 101 (5). If a result looks too small, check for a stray character.
Prefixes. Code often writes 0x for hex, 0b for binary and 0o for octal. Enter the digits without a prefix to be safe. Beware legacy C and older JavaScript, where a leading zero alone, as in 010, means octal 8.
Precision limits. JavaScript numbers are 64-bit floating point and represent integers exactly only up to 2⁵³ − 1, which is 9,007,199,254,740,991. Beyond that, conversions lose precision; use BigInt for 64-bit IDs and large hashes.
Negative numbers. A negative input is shown with a minus sign, such as -11111111. Hardware stores negatives in two's complement, where −1 in 8 bits is 11111111, so do not confuse the two representations.
Fractions are not supported, since only whole numbers are converted. Everything runs locally and your last input is remembered.