Number Base Converter Calculator | How Computers Represent Numbers

There Is No Number 42 Inside a Computer

Only ever a pattern of on and off. Every base conversion, every negative sign, every decimal point is a convention layered on top of that one physical fact. Here is how those conventions were built, and why each one is shaped the way it is.

number base converter calculator

Last updated: July 2026

🔴 Why binary, and not decimal

A transistor is a switch. It is reliably on or reliably off, and building a component that reliably holds ten distinct voltage levels for decimal digits is far harder and far less noise-tolerant than building one that only has to distinguish two. Binary was not chosen for elegance; it was chosen because two-state circuits are the ones that could actually be built cheaply and made to work reliably at scale. Every other number system in a computer — octal, decimal, hexadecimal — is a human convenience layered on top, a shorthand for grouping those same binary digits into more readable chunks. Hexadecimal in particular exists because one hex digit represents exactly four binary digits, so a byte becomes two tidy hex characters instead of eight bits to squint at.

🟡 The negative-number problem, and the trick that solved it

Prime Tool Hub Video Tutorial — Watch on YouTube

Representing a negative number sounds like it should be simple: flip a bit to mean minus. That approach, called sign-magnitude, works for reading but fails for arithmetic. Add positive five to negative five in sign-magnitude and the circuit has to specifically detect that the signs differ and subtract instead of add — an entirely separate code path from ordinary addition. Worse, it produces two representations of zero, positive zero and negative zero, which is wasteful and creates edge cases in comparisons.

Two’s complement solves this with a small piece of arithmetic cleverness: to negate a number, invert every bit and add one. The payoff is that plain binary addition, run without any modification at all, produces correct results whether the operands are positive or negative. Overflow becomes a simple, mechanical check rather than a special case. This is precisely why every mainstream processor since the 1960s uses it — it is not the most intuitive representation to read, but it is the cheapest to build correct hardware for, and cheap, correct hardware wins.

The range asymmetry that confuses people — 8-bit signed running from -128 to 127, not -127 to 127 — falls directly out of this scheme. There are 256 possible bit patterns in 8 bits. Zero uses one of them, and the remaining 255 split unevenly between positive and negative because two’s complement has no separate negative zero to burn a second slot on, leaving one extra pattern for the negative side.

🟢 Floating point: trading exactness for range

IEEE 754 float split into sign, exponent and mantissa fields

Integers are exact but limited in range. Real engineering needs numbers that span from atomic-scale fractions to astronomical magnitudes, and no fixed number of bits can represent all of those exactly — something has to give. IEEE 754’s answer is scientific notation in binary: a sign bit for positive or negative, an exponent field that says how far to shift the point, and a mantissa that stores the significant digits. This is the same idea as writing 3.14 x 10², just in base two with a fixed budget of bits for each part.

The exponent field also does double duty encoding special values. An all-ones exponent signals something outside the normal number line entirely — paired with a zero mantissa it means Infinity, the result of dividing by zero; paired with a non-zero mantissa it means NaN, not-a-number, the result of an undefined operation like zero divided by zero. An all-zero exponent means either signed zero or a denormal number, a special reduced-precision scheme for representing values too close to zero for the normal format to reach. These are not arbitrary error codes bolted on afterward — they are built into the same bit layout every ordinary float uses, which is why a float can silently become Infinity or NaN and keep propagating through a calculation without ever throwing an error.

The famous surprise, that 0.1 plus 0.2 does not equal 0.3 in most programming languages, follows directly from this design. Binary fractions can only exactly represent sums of powers of two — one half, one quarter, one eighth — the same way decimal can only exactly represent sums of powers of ten. Just as one-third has no exact finite decimal representation, one-tenth has no exact finite binary representation. The mantissa stores the closest value that fits in its bit budget, and that tiny rounding error is what resurfaces later as an unexpected 0.300000000000000004.

🔴 Where this actually bites in real work

Integer overflow is not an academic curiosity — it is the mechanism behind a category of real security bugs, where a value silently wraps past its maximum and becomes a small or negative number instead of erroring, sometimes bypassing a bounds check entirely. Floating-point rounding is why financial software avoids plain floats for money and uses fixed-point or integer-cents arithmetic instead, and why comparing two floats for exact equality is a well-known beginner mistake — you compare within a small tolerance instead. Understanding the bit layout is what turns these from mysterious bugs into predictable, checkable behaviour.

Once you are comfortable with how a number is stored, the natural next layer is how numbers combine into logic. The Boolean Algebra Studio and Truth Table Generator cover the logic gates that manipulate these bits, and the 7400 Series IC Finder shows the physical chips that once implemented exactly this arithmetic in hardware. To see any of these representations directly, work through them in the Number Systems Studio, which shows the bit grid for two’s complement and IEEE 754 exactly as described here.

❓ Frequently Asked Questions

Why do computers use binary instead of decimal?

Because a transistor reliably distinguishes two states, on and off. Building hardware that reliably holds ten distinct decimal levels is far harder and less noise-tolerant at scale.

Why does two’s complement exist instead of a plain sign bit?

A plain sign bit (sign-magnitude) needs special-case logic for addition and creates two zeros. Two’s complement lets ordinary binary addition work correctly on negative numbers with no extra logic.

Why is 8-bit signed range -128 to 127, not -127 to 127?

There are 256 total bit patterns. Zero takes one, and because two’s complement has no separate negative zero, the remaining 255 split unevenly, leaving one extra pattern on the negative side.

Why doesn’t 0.1 + 0.2 equal 0.3 exactly?

Binary fractions can only exactly represent sums of powers of two, the same way decimal can only exactly represent sums of powers of ten. A tenth has no exact finite binary form, so a tiny rounding error appears.

What is a NaN and where does it come from?

Not-a-Number, produced by an undefined operation like zero divided by zero. It is encoded as an all-ones exponent with a non-zero mantissa, built directly into the IEEE 754 bit layout.

Is integer overflow just a theoretical concern?

No. It is a real category of software bugs and security vulnerabilities, where a value silently wraps past its maximum into a small or negative number instead of raising an error.

Why shouldn’t I use floats for money?

Because floating point cannot represent most decimal fractions exactly, and small rounding errors accumulate. Financial software typically uses fixed-point or integer-cents arithmetic instead.

Why is hexadecimal used so often in programming?

Because one hex digit represents exactly four binary digits, so a full byte becomes a tidy two-character hex value instead of eight bits, making binary data far easier for a human to read.

Choose a language

Top Tools Ranking

Network Total Views
4,940
Tracking Since
Jul 9, 2026

Click any tool to open in a new window