Number Base Converter: Binary, Hex and the Awkward Part About Negatives
Converting a positive integer between bases is arithmetic anyone can do on paper. Representing a negative one is where converters diverge, because there are two entirely different correct answers and which you want depends on whether a person or a processor is reading it. This tool shows both, computes everything with BigInt so 64 bit values stay exact where floating point silently rounds, and says plainly when a value will not fit the width you chose. Everything runs in your browser.
Table of Contents
What a Base Actually Is
The base is how many digits you have. Ten digits in decimal, two in binary, sixteen in hexadecimal. When you run out, you add a column.
Each column is worth the base times the one to its right. In decimal the columns are ones, tens and hundreds. In binary they are ones, twos and fours.
The number does not change, only the writing. 255, ff and 11111111 are the same quantity in three notations, which is worth remembering when a value looks unfamiliar.
Beyond base ten, letters continue the digits. A is ten, b is eleven, and so on up to z as thirty five, which is why base 36 is the practical ceiling.
How to Use This Converter
Type the value and say what base it is in. Everything else follows immediately, and invalid digits are named rather than ignored.
Paste with prefixes if you have them. 0x, 0b and 0o are all accepted, as are spaces and underscores between groups of digits.
Try a negative number. The base list shows the readable form with a minus sign, and the bit pattern panel shows what actually gets stored, which are not the same thing.
Switch the width. The same negative value is a different pattern at each width, and the tool tells you when the value does not fit rather than truncating quietly.
Binary and Why Computers Use It
Two states are easy to build reliably. A voltage is either above a threshold or below it, and distinguishing two levels is far more robust than distinguishing ten.
It makes numbers long. A value that takes three decimal digits takes eight binary ones, which is why nobody reads raw binary if they can avoid it.
Grouping is essential. Four bit groups map exactly to one hex digit, which is why the pattern above is grouped that way rather than run together.
Eight bits is a byte. The unit almost everything else is built from, holding 0 to 255 unsigned, or -128 to 127 signed.
Hexadecimal as Shorthand
One hex digit is exactly four bits. That clean mapping is the entire reason hex exists in computing, and it is why converting between hex and binary needs no arithmetic at all.
A byte is two hex digits. Which makes ff the largest byte, and makes colour codes, memory addresses and file dumps readable at a glance.
Case does not matter. FF and ff are the same value. Lower case is the more common convention in code and upper case in documentation.
The 0x prefix is a convention, not part of the number. It tells a compiler or a reader how to interpret the digits that follow.
Two Complement Explained
The top bit is the sign. One means negative, and the remaining bits are not the magnitude, which is the part that surprises people first.
Negate by inverting and adding one. Flip every bit, add one, and you have the negative. Applying it twice returns the original, which is what makes the scheme consistent.
It exists so subtraction is addition. A processor can subtract by adding the two complement, so one adder circuit handles both operations. That is the whole reason the representation won.
The range is asymmetric. Eight bits hold -128 to 127, one more negative value than positive, because zero occupies a slot on the positive side.
Bit Widths and Overflow
The width decides the range. Eight bits signed reach 127, sixteen reach 32767, and thirty two reach a little over two billion.
Overflow wraps rather than erroring. Adding one to the largest positive value produces the most negative one, silently, in most languages.
That two billion limit caused real problems. Signed 32 bit counters overflowing is behind a long list of production incidents, including view counters and timestamp handling.
The tool refuses rather than wrapping. When a value does not fit the chosen width it says so, because silently producing the wrapped pattern would be a worse answer than no answer.
Why BigInt Rather Than Numbers
JavaScript numbers are doubles. They hold integers exactly only up to about nine quadrillion, which is 2 to the power of 53.
64 bit values exceed that. Converting one through a regular number loses the low digits, and the result looks entirely plausible while being wrong.
BigInt is exact at any size. Every conversion here goes through it, which is why a 64 bit hex value round trips to the same digits it started with.
This is worth checking in other tools. Paste sixteen f characters as hex and see whether the decimal ends in 615 or in 000. The second means the tool is using floating point.
Octal, Base 36 and the Rest
Octal is three bits per digit. Once common because early machines used word sizes divisible by three, and now mostly seen in Unix file permissions.
A leading zero used to mean octal. In C and several descendants, which is a genuine source of bugs when someone pads a decimal number with a zero.
Base 36 uses every digit and letter. It gives the shortest representation available in plain alphanumerics, which is why short identifiers and URL shorteners reach for it.
Base 64 is a different thing entirely. It encodes bytes rather than numbers, using a fixed alphabet of sixty four characters, and it is not a positional number base in this sense.
Common Mistakes to Avoid
Reading a two complement pattern as a magnitude. 11111111 is not 255 when the type is signed. It is minus one.
Assuming a converter is exact at 64 bits. Many are not, and the failure is silent. Check with sixteen f characters.
Forgetting the width when sharing a bit pattern. A pattern without its width is ambiguous, since the same bits mean different values at different widths.
Padding a decimal number with a leading zero. In several languages that makes it octal, so 010 is eight.
Frequently Asked Questions
A precision note: every conversion here uses BigInt, so 64 bit values keep every digit. If another tool gives you a decimal ending in zeros for sixteen hex f characters, it is doing the arithmetic in floating point and losing the low digits.