Home/Converters/Number base converter
ConverterNumber Base Converter
Type a number into any of the four fields and the rest update immediately. Handles arbitrary size — this is not limited to 32-bit numbers — plus any base from 2 to 36 for the odd cases those four don't cover.
Two's complement (for negative values)
—
Pick a bit width below to see how a negative number is actually stored.
Two's complement: how computers actually store a negative number
There is no minus sign in binary storage. Instead, virtually every processor uses two's complement: to represent −n in a fixed width of w bits, take 2w and subtract n, then store that as an ordinary unsigned binary number.
| Step | Value |
|---|---|
| Start with +5 | 00000101 |
| Invert every bit (one's complement) | 11111010 |
| Add 1 | 11111011 |
| Check: 256 − 5 | 251 = 11111011 ✓ |
The reason the whole industry standardised on this rather than a simple sign bit: two's complement lets addition and subtraction use the exact same hardware circuit for both positive and negative numbers, with no special case. 5 + (−5) in 8-bit two's complement is 00000101 + 11111011 = 100000000, which overflows the 8-bit register and leaves exactly 00000000 — zero, correctly, with no extra logic required.
It also explains the lopsided range: an 8-bit two's complement value runs from −128 to +127, not −127 to +127. Zero uses up one of the 256 available patterns, and it only needs one, so the negative side gets the extra value that a sign-bit scheme would have wasted on "negative zero".
Why 0.1 never terminates in binary
Binary fractions terminate only when the denominator, fully reduced, is a power of two. 0.5 is 1/2, 0.25 is 1/4, 0.125 is 1/8 — all fine. 0.1 is 1/10, and 10 factors into 2 × 5. That leftover factor of 5 means no finite number of binary digits can express it exactly, in exactly the same way 1/3 cannot be written as a finite decimal.
A 64-bit double-precision float storing "0.1" actually holds:
0.1000000000000000055511151231257827021181583404541015625
That tiny discrepancy is why 0.1 + 0.2 famously does not equal 0.3 in JavaScript, Python, or almost any language using IEEE 754 floating point — both operands are already slightly wrong before the addition even happens.
How many digits a number needs in a given base
The digit count follows directly from what a base actually means: with b possible digits per position, d positions can represent bd distinct values. Solving for the smallest d that covers a number n gives the formula this converter uses to report digit counts:
digits = ⌊logb(n)⌋ + 1
| Base | Calculation | Digits | Representation |
|---|---|---|---|
| Binary (2) | ⌊log₂100000⌋+1 = ⌊16.61⌋+1 | 17 | 11000011010100000 |
| Octal (8) | ⌊log₈100000⌋+1 = ⌊5.54⌋+1 | 6 | 303240 |
| Decimal (10) | ⌊log₁₀100000⌋+1 = ⌊5⌋+1 | 6 | 100000 |
| Hexadecimal (16) | ⌊log₁₆100000⌋+1 = ⌊4.15⌋+1 | 5 | 186A0 |
Decimal is the one edge case worth watching: when n is an exact power of the base, logb(n) is a whole number and the floor does nothing extra — 100,000 is 105, so log₁₀ gives exactly 5, and adding 1 correctly gives 6 digits, matching "100000" having six characters.
Questions people ask
Is there a limit to how large a number this converter handles?
No fixed limit for the main four fields and the arbitrary base — they use arbitrary-precision integers, not the 32-bit or 64-bit registers a real processor uses. The two's complement panel is deliberately limited to a chosen bit width, because two's complement only means something once you fix how many bits you're working with.
Why does octal not get a two's complement mode?
Two's complement is defined for a fixed number of bits, and octal digits each represent 3 bits — a bit width like 8, 16 or 32 doesn't divide evenly into whole octal digits. Binary and hexadecimal both divide cleanly (1 bit and 4 bits per digit), which is why negative octal here is shown with a plain minus sign instead.
What happens if I type an invalid digit for the base?
The field's own value is left as you typed it and an error appears rather than the tool guessing what you meant or silently producing zero — for instance "2" is not a valid binary digit, and "G" is not valid in base 16.