Number Base Converter
Convert between binary, octal, decimal and hexadecimal. Uses arbitrary-precision arithmetic, so values larger than 64 bits are handled exactly.
| Analysis | Type a number into any of the four fields above. |
Bitwise operations
Both operands accept any base. Shifts treat B as a plain decimal bit count.
| Result | Shown here in all four bases. |
Why this converter never rounds
Every other number-base converter you have used probably breaks somewhere around 15 digits,
and the reason is floating point. JavaScript numbers are IEEE 754 doubles, which hold exact
integers only up to 253 − 1. Past that, 9007199254740993 and
9007199254740992 become the same value.
This tool converts through BigInt, which is arbitrary precision. A
256-bit hash, a 128-bit IPv6 address or a 300-digit number all convert exactly, in both
directions. That is also why shift and mask results here stay correct for values far beyond
what a 64-bit register could hold.
| Base | Prefix | Digits | Typical use |
|---|---|---|---|
| 2 | 0b | 0 1 | Bitmasks, flags, permissions |
| 8 | 0o | 0-7 | Unix file modes such as 0644 |
| 10 | none | 0-9 | Everything humans read |
| 16 | 0x | 0-9 a-f | Memory addresses, colours, hashes, byte dumps |
Prefixes are accepted on any input. Typing 0x1F into the decimal field works and
is interpreted as hexadecimal, which is handy when you are pasting values around quickly.
Two's complement, briefly
A bit pattern has no inherent sign. The byte 0xFF is 255 if you read it as unsigned,
and −1 if you read it as a signed 8-bit integer. The rule: if the top bit of the chosen
width is set, subtract 2width from the unsigned value.
That is why the analysis panel reports signed interpretations at 8, 16, 32 and 64 bits separately rather than guessing one for you — the same 32-bit pattern legitimately means different things depending on the type you declared in your program.
What people actually use this for
- Permission bits.
0755is not the number seven hundred and fifty-five. It is three octal digits: owner7(rwx), group5(r-x), others5. - Feature flags. One integer where each bit is a boolean. Test with
flags & (1 << n), set withflags | (1 << n), clear withflags & ~(1 << n). - Colour channels.
0x1A2B3Cis three bytes: red1A, green2B, blue3C. The byte breakdown below shows exactly that split. - Network masks and subnets. A
/24is0xFFFFFF00as a 32-bit mask.
Frequently asked questions
Why does my decimal value come back slightly wrong elsewhere?
You have exceeded 253 − 1 and the other tool is using floating point. Values up to that limit are exact in a double; beyond it they are not.
Can I convert fractions such as 0.1?
No. This tool handles integers only, because positional conversion of fractional parts produces repeating expansions in most bases and is rarely what you want when working with bit patterns.
Why does a shift give a huge number?
Shifting left by n multiplies by 2n. With arbitrary precision there is no overflow, so 1 << 200 really is a 61-digit number rather than wrapping to zero.
What does "popcount" mean?
Population count: the number of bits set to 1. It is the standard way to answer "how many flags are enabled" on a bitmask and has a dedicated CPU instruction on most modern processors.
Privacy. All arithmetic runs in your browser. Numbers you paste here are never transmitted, which makes this safe for real keys, tokens and addresses.