Skip to main content

Number Base Converter

Convert exact signed integers between bases 2–36, including binary, decimal, octal, and hexadecimal. See positional steps and optional signed two’s-complement encoding.

Interested in Advertising?

Tell us more, and we'll get back to you.

Contact Us

About Number Base Converter

Practical context, assumptions, examples, and next steps for using the result well.

What a number base means

A number base, also called a radix, determines how many different digit values a positional numeral system uses. Decimal uses ten digits because its base is ten. Binary uses two digits because its base is two. Changing the base changes the written representation, not the integer being represented. Twelve objects remain twelve objects whether their count is written as decimal 12, binary 1100, or hexadecimal C. This distinction matters whenever a display, file format, programming language, or classroom exercise uses a different notation from the one you normally read.

Position gives each digit its weight. In decimal 247, the rightmost seven counts ones, the four counts tens, and the two counts hundreds. Those weights are successive powers of ten. In base seven, the same written digits would count ones, sevens, and forty-nines, but the digit 7 itself would not be allowed. A representation is therefore incomplete without knowing its base. Even the familiar string 10 means the value of the base, rather than necessarily the decimal quantity ten.

This number base converter supports signed whole integers in every base from two through thirty-six. Choose the source base, enter the digits, and choose the destination base. The main result uses ordinary signed notation. Decimal, binary, octal, and hexadecimal equivalents are displayed together so you can compare representations without repeatedly changing the destination. The optional bit-width control serves a separate purpose: encoding a signed integer in a fixed-width two’s-complement format.

The digit alphabet and accepted input

The alphabet is 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ. Digits zero through nine retain their familiar values. A has value ten, B has value eleven, and the sequence continues to Z with value thirty-five. A base uses only the first part of that alphabet: base sixteen ends at F, base twenty ends at J, and base thirty-six can use every character. Lowercase input is accepted as an equivalent spelling; output letters are uppercase. This is a common radix convention, not a general decoder for every custom alphabet used by identifiers or encodings.

The entire input must be a valid integer in the selected base. A single leading plus or keyboard minus sign is allowed, and surrounding whitespace is ignored. Spaces inside the digits, underscores, commas, decimal points, exponent notation as a numeric syntax, and fraction bars are not supported. For decimal one thousand, enter 1000 rather than 1,000 or 1e3. In bases that contain E, the character E is an ordinary digit, so 1E3 can legitimately mean a nondecimal integer rather than a scientific-notation expression.

Do not add programming-language prefix markers. To convert hexadecimal 0xFF, enter FF and select base sixteen. The parser never strips 0x, 0b, or 0o. An invalid letter produces an error; in a higher base where every character happens to be legal, the characters are interpreted literally as digits instead. Leading zeros are accepted and do not change the mathematical value. The result is normalized, so redundant leading zeros and an unnecessary plus sign disappear, while negative zero becomes zero.

Evaluate an integer with positional weights

The positional formula multiplies each digit by a power of the base and adds the products. Starting at the right, the exponents are zero, one, two, and so on. Because any nonzero base raised to zero is one, the rightmost digit always contributes its own value. Hexadecimal 2AF therefore means two times sixteen squared, plus ten times sixteen, plus fifteen. The sum is 512 plus 160 plus 15, which is decimal 687. The letters do not change the formula; they supply digit values larger than nine.

The step preview uses an equivalent left-to-right method called repeated multiply-and-add, or Horner evaluation. Start with a running total of zero. Read the next digit, multiply the running total by the source base, then add the digit’s numeric value. For 2AF in base sixteen, the totals are 2, then 42, then 687. Each multiplication shifts the previous digits one place to the left before the new digit is appended. This avoids explicitly constructing a separate large power for every position.

The preview shows at most sixteen input-digit steps to keep the page usable for long values. An omission message tells you when more steps exist, and the exact result still includes all accepted digits. For a negative input, these steps evaluate the magnitude first; the minus sign is applied afterward. This is not an approximation or a truncation of the calculation. It is only a bounded explanation of a process that continues in the same way for every remaining digit.

Convert the value with repeated division

Once the value is known, repeated division gives its representation in the destination base. Divide the nonnegative magnitude by the destination base, record the remainder, and continue dividing the quotient until it becomes zero. Every remainder is smaller than the base, so it corresponds to one allowed digit. The first remainder is the least significant digit. Read the collected remainders in reverse order to construct the answer. If the original integer was negative, place a minus sign before the completed representation.

For example, decimal 687 divided by sixteen has quotient 42 and remainder 15, which is F. Dividing 42 by sixteen gives quotient 2 and remainder 10, which is A. Dividing 2 by sixteen gives quotient zero and remainder 2. Reading backward gives 2AF, matching the positional calculation. For a base-seven example, decimal 100 gives remainder 2 and quotient 14, then remainder zero and quotient 2, then remainder 2 and quotient zero. The result is 202 in base seven.

Zero needs a small special case in a handwritten division procedure: its representation is simply 0, not an empty string. An equal source and destination base also needs no change of value, although the converter can still normalize letter case, signs, and leading zeros. Converting between unfamiliar bases does not require rounding through a decimal approximation. Decimal is useful for explaining intermediate values, but the arithmetic can remain exact throughout, and the destination digits are determined solely by integer quotients and remainders.

Why binary, octal, and hexadecimal fit together

Binary is especially useful for understanding digital state because each digit represents a bit. Its place values are one, two, four, eight, sixteen, and successive powers of two. Binary 101101 equals 32 plus 8 plus 4 plus 1, giving decimal 45. A one marks an included power; a zero marks an excluded power. This representation is longer than decimal but makes bit patterns visible, which helps when reading flags, masks, instruction fields, or examples in computer architecture.

Octal groups binary into three-bit chunks because eight equals two cubed. Hexadecimal groups it into four-bit chunks because sixteen equals two to the fourth power. For the binary magnitude 101101, grouping from the right gives octal chunks 101 and 101, yielding 55. Four-bit grouping gives 0010 and 1101 after padding the leftmost group, yielding hexadecimal 2D. The padding is a reading aid and does not change the integer. Group from the least significant end so the positional boundaries remain aligned.

These shortcuts concern magnitudes or explicitly sized bit patterns, not an automatic interpretation of negative values. Decimal -45 becomes signed binary -101101 and hexadecimal -2D in the main output. A byte-oriented format might instead encode it as a two’s-complement pattern, but that requires a width. Likewise, converting an integer to hexadecimal does not specify byte order. Endianness describes how multiple bytes are arranged in storage or transmission; this tool writes the most significant digit first and does not reverse byte sequences or decode text encodings.

Separate a negative sign from two’s-complement encoding

Ordinary signed notation and two’s complement answer different questions. A signed numeral writes a minus sign followed by a magnitude and has no inherent bit width. Two’s complement encodes a signed value using exactly a chosen number of bits. For a width of w bits, its signed range starts at negative two raised to w minus one and ends at positive two raised to w minus one, minus one. The negative side has one additional value because the all-zero pattern represents zero rather than a second signed zero.

In eight bits, the range is -128 through 127. Positive values are encoded in ordinary binary with leading zeros to fill the width. A negative value is encoded by adding it to two raised to the width: negative one becomes 256 minus one, or binary 11111111. Negative 128 becomes 10000000. The same eight bits interpreted as unsigned would mean 128, demonstrating why a bit pattern alone does not determine signedness. Selecting a width here does not change how the source digits are parsed.

The optional encoding checks representability before displaying anything. Decimal 128 cannot be encoded as a signed eight-bit positive value, and decimal -129 cannot fit either. Rather than discarding high bits or silently wrapping the number, the calculator asks for a larger width or for the option to be turned off. The binary output includes every bit, and hexadecimal is padded to the corresponding digit width. This is a representation aid, not a simulation of a language’s overflow behavior, integer casts, or arithmetic shift rules.

Exact integers and sensible browser limits

Many everyday JavaScript calculations use floating-point Number values. Those values cannot distinguish every integer once the magnitude exceeds the safe integer range. A base converter that parses a long integer into a Number before formatting it may therefore output a plausible but incorrect final digit. This converter accumulates accepted digits using BigInt integer arithmetic instead. The integer result is never passed through a floating-point value, and output is formatted directly in the requested radix. Large identifiers and mathematical examples retain every input digit.

Exactness does not mean unlimited input. The maximum accepted magnitude is 4,096 source digits, excluding an optional sign. That is a text-size limit, not a bit-size limit: 4,096 base-thirty-six digits represent a much larger magnitude than the same number of binary digits. Consequently, a valid output may contain more characters than the input. Results remain textual, with wrapping and a scrollable area for lengthy values. The explanation preview is bounded independently, so a long integer does not create thousands of instructional rows.

The optional signed encoding is capped at 4,096 bits and can reject an integer that is otherwise valid for ordinary conversion. Turning it off restores the unrestricted signed representation within the input cap. Inputs are included in the page URL so a calculation can be revisited or shared. Treat those URLs as containing the entered values; do not paste secret keys or confidential identifiers into a public sharing workflow. Conversion itself requires no external lookup or network service, but a local calculation is not a reason to expose sensitive data.

Check results and avoid common interpretation errors

A useful verification is a round trip: convert the result back from its destination base to its original base. The normalized digits should match the original magnitude, apart from letter case, leading zeros, and a redundant plus sign. For a smaller example, independently expand the result with positional weights. Decimal 255 becomes hexadecimal FF because fifteen times sixteen plus fifteen is 255. Its binary result contains eight ones because the sum of powers from two to the seventh down through two to zero is 255.

When the tool reports an invalid digit, check the source base before editing the number. The letter F is valid in hexadecimal but not in decimal. The digit 2 is invalid in binary. A minus sign belongs only at the beginning, and a decimal point is not an accepted integer character. If a fixed-width error appears, compare the value with the signed range rather than the unsigned capacity. An eight-bit storage field and a signed eight-bit integer do not have the same maximum positive value.

Finally, identify what the input actually represents. A string that looks hexadecimal could be a byte sequence, a color, a checksum, a character encoding, or an integer. This tool handles the integer interpretation only; it does not preserve a requested byte length unless you explicitly choose a compatible signed encoding. It does not decode ASCII, floating-point bit layouts, fractions, or arbitrary base alphabets. Making the representation and interpretation explicit is the most important step in obtaining an answer that is not just arithmetically correct, but useful for your actual task.

Frequently Asked Questions

What does converting a number base change?

A base conversion changes the digits used to write an integer, not its value. Decimal 255, hexadecimal FF, octal 377, and binary 11111111 all represent the same quantity. Select the base of the input before interpreting its digits.

Which digits can I use in bases above ten?

The converter uses 0–9 for values zero through nine and A–Z for values ten through thirty-five. Lowercase letters have the same values as uppercase letters. For example, Z is valid in base 36 but not in base 16; hexadecimal stops at F.

Does the converter preserve integers larger than JavaScript’s safe integer limit?

Yes. The input is accumulated with BigInt arithmetic rather than converted to a floating-point Number, so every accepted digit is retained exactly. Input is limited to 4,096 digits excluding the optional sign to bound browser work; output length depends on the target base.

Why is -1 different from 11111111 in binary?

Ordinary signed notation writes negative one as -1 in every supported base. An eight-bit two’s-complement encoding writes the same signed value as 11111111, but only when that width and signed interpretation are specified. This tool treats input digits as an ordinary signed integer and provides two’s complement as a separate optional output.

Why does 255 fail with signed eight-bit two’s complement enabled?

A signed eight-bit integer ranges from -128 to 127, even though an unsigned eight-bit integer can represent 255. This converter checks the signed range and refuses to wrap an out-of-range input. Select sixteen bits or turn the optional encoding off to convert 255.

Can I enter fractions, hexadecimal prefixes, or separators?

This integer converter does not accept fractions, decimal points, commas, underscores, or explicit prefix notation. For hexadecimal 0xFF, enter FF and select base 16; for binary 0b101, enter 101 and select base 2. In bases where letters such as X are valid digits, those letters are interpreted as digits, never as prefix markers.