HandyTools Hub

Number Base Converter

Convert between binary, octal, decimal, and hexadecimal number systems.

Input

Results

How Base Conversion Works

Every number system is positional: the value of a digit depends on where it sits. The integer part of a number is the sum of each digit multiplied by the base raised to its position, counting from zero at the right. To convert, the tool parses the cleaned input into a JavaScript number and re-encodes it in the target base. Fractions are handled separately. Each fractional digit is worth that digit divided by the base raised to its position, and to emit the result the tool repeatedly multiplies the fraction by the target base, takes the whole part as the next digit, and keeps the remainder. That repeated multiplication is why non-terminating fractions get cut off.

Before any of this, the input is cleaned: underscores, commas, and spaces are removed, and letters are uppercased. That lets you paste grouped binary like 1111_0000 or formatted decimal like 1,024 without pre-processing.

Worked Examples

Simple integer. Decimal 255 becomes binary 11111111, octal 377, and hex FF. Reading it back: 255 is 2^8 - 1, so binary is eight ones and hex uses two F digits, each worth 15.

Hex with letters. Hex 1A4 becomes decimal 420. Check it: 1 x 256 + 10 x 16 + 4 = 420. In binary that is 110100100 and in octal 644.

A fraction that repeats. Decimal 0.1 becomes binary 0.00011001, octal 0.06314631, and hex 0.19999999. All three are truncated approximations of a value that has no exact finite form in those bases.

A binary fraction. Binary 1010.101 becomes decimal 10.62500000, octal 12.5, and hex A.A. The fractional part .101 is 1/2 + 0/4 + 1/8 = 0.625.

Accepted Inputs and Prefixes

BaseDigitsPrefix for output
Binary (2)0-10b
Octal (8)0-70o
Decimal (10)0-9none
Hexadecimal (16)0-9, A-F0x

The prefix buttons add a decoration to the copied result. They only apply to the result row whose base matches the base you selected on the input side. For example, if you enter a hexadecimal value and choose 0x, only the hexadecimal row is prefixed; the binary, octal, and decimal rows stay plain. Switch the input base and the prefix moves with it, because it is always tied to the source base, not applied globally.

Precision and Limitations

  • Fractions are capped at eight digits and truncated, not rounded. Expect a small error on any value that repeats in the target base.
  • The decimal row pads fractions to eight places. 0.5 shows as 0.50000000; other bases trim trailing zeros.
  • Integers are limited to JavaScript’s safe range (2^53 - 1). Larger values may lose digits.
  • Negative numbers are rejected. The minus sign is not a valid digit.
  • Only bases 2, 8, 10, and 16 are available. Base 32, 36, and arbitrary bases are not supported.
  • Output is always uppercase. Lowercase hex input is accepted but never produced.
  • Leading zeros are stripped. 000255 converts the same as 255.

Common Mistakes

  • Treating 10 in binary as ten. It is two; the digit positions are powers of two.
  • Typing a prefix into the input. 0x1F fails in the hex field because x is not a hex digit; enter 1F and use the toggle.
  • Expecting exact binary fractions. Values like 0.1 are approximations after eight digits.
  • Using a comma as a decimal separator. Commas are stripped as grouping, so 1,5 is read as 15, not 1.5.
  • Assuming the prefix applies to every row. It only decorates the row matching the selected input base.

Real-World Scenarios

Web color channels. A CSS hex color such as FF5733 is three bytes written in base 16. Convert each pair separately by entering FF, 57, and 33 with the base set to hexadecimal: they become decimal 255, 87, and 51, which is exactly the RGB triplet. The tool converts the whole value, so split the six-digit string into pairs first.

Unix file permissions. Permission modes like 755 are read in octal, not decimal. Convert 755 from base 8 and you get binary 111101101, which groups as 111 (read, write, execute) for the owner, 101 for the group, and 101 for others. Decimal 493 is the same value, which is why a permissions calculator is a better fit for that specific job.

Bitmasks and flags. A mask written as binary 00001111 is decimal 15 and hex F. Converting between these makes it easier to reason about which bits are set.

Debugger addresses. A crash log might show address 0x7FFE0A10. Convert it from hex to decimal 2147352592 or to binary when you need to inspect individual bits.

Two shortcuts let you verify the tool’s output quickly. To go from binary to hex, group the bits into nibbles of four from the right and convert each nibble: 110100100 becomes 1 | 1010 | 0100, which is 1A4. To go from binary to octal, group into threes instead: 110 | 100 | 100 becomes 644. Both match the earlier example, so if your manual grouping disagrees with the converter, recheck where you started grouping. Remember to group from the right, and pad the leftmost group with zeros only if you need a fixed width.

Frequently Asked Questions

Why doesn't 0.1 decimal convert to a short binary fraction?

Because one tenth has no exact representation in base two. Converting a fraction means repeatedly multiplying by the target base and collecting the whole parts, and 0.1 produces the repeating sequence 0001100110011... forever. The converter stops after eight fractional digits and truncates rather than rounds, so the binary output is 0.00011001. The same limit means 0.1 in hexadecimal shows as 0.19999999. Fractional results are approximations, not exact values.

Can I enter a negative number?

No. The minus sign is not a valid digit in any of the four supported bases, so a value like -5 is rejected with an invalid-input error. The converter handles magnitudes only. If you need sign handling, strip the minus, convert the magnitude, and add the sign back in your own code.

Does the input field accept 0x, 0b, or 0o prefixes?

No. The prefix buttons control whether the copied output is decorated for use in source code; they do not enable prefix parsing on input. Typing 0x1F into a hexadecimal field fails because the x is not a hex digit. Enter the digits only, and use the toggle to add a prefix to the result you copy.

Why does the decimal row show eight digits after the decimal point?

Fractional conversion works by producing eight target-base digits and, for the decimal row specifically, the code keeps all eight rather than trimming trailing zeros. So a simple value like 0.5 appears as 0.50000000 and 10.625 as 10.62500000. For the binary, octal, and hex rows the trailing zeros are stripped, so the binary row shows 0.1 for the same input.

How large a number can it convert exactly?

Integer conversion routes through JavaScript numbers, so values are exact only up to 2^53 - 1, which is 9,007,199,254,740,991. Beyond that the intermediate decimal value is rounded and the digits you get back in other bases may not match the original. For very large integers, use a language with arbitrary-precision integers or a dedicated big-number library.

Why is my hexadecimal output shown in capital letters?

The tool normalizes input and output to uppercase for consistency. It also strips underscores, commas, and spaces before parsing, so you can paste a grouped value like 1111_0000 or 1,024 and it will convert cleanly. Case does not affect the value: ff and FF both mean 255.

Reviewed by the HandyTools Hub team · Last updated