Number Base Converter
Convert between binary, octal, decimal and hex, build a value bit by bit, and run bitwise operations. Everything is computed in your browser.
Convert a number
Precision: this panel uses JavaScript BigInt, so it supports integers of any size, positive or negative. Negative values are shown in sign-magnitude form (e.g. -101) — there's no declared bit width here, so two's complement doesn't apply. For fixed-width two's complement, use the bits/bitwise panel below.
Results
- Binary
- —
- Octal
- —
- Decimal
- —
- Hexadecimal
- —
Bits & bitwise operations
Bit width is explicit and required: NOT and shift only mean something relative to a declared width, so pick 8/16/32/64 above rather than assuming one. Values are stored as the raw bit pattern for that width — typing a value larger than the width fits (or shifting past the edge) wraps/truncates the same way a real fixed-width register would, and the line under each input shows exactly what got stored.
Result
- Width
- —
- Binary
- —
- Octal
- —
- Decimal (unsigned)
- —
- Decimal (signed)
- —
- Hexadecimal
- —
What is a number base?
A number base (or radix) is how many distinct digits a counting system uses before it carries over into a new place value. Decimal (base 10) is what people use day to day; computers work natively in binary (base 2), and developers use octal (base 8) and hexadecimal (base 16) as compact, human-readable stand-ins for binary — one hex digit always maps to exactly 4 bits, and one octal digit to exactly 3, which is why file permissions (chmod), color codes and memory addresses are so often written in those two bases instead of raw binary.
How to use Number Base Converter
- In "Convert a number," pick the base your value is currently written in, then type it (or click Example).
- Read the same value in all four bases under Results — this panel supports arbitrarily large integers and negative numbers.
- In "Bits & bitwise operations," pick a bit width (8/16/32/64) — this determines how NOT, shift, and the individual-bit view behave.
- Type Value A (and B, for AND/OR/XOR) in any base — prefix with
0b,0oor0x, or leave unprefixed for decimal — or click individual bits under Value A to toggle them directly. - Pick an operation and (for shifts) an amount, and read the Result panel.
How the conversions and bitwise math work
The top panel treats a number as a plain, arbitrary-size integer with no fixed width, converting it between bases with JavaScript's native BigInt. For example:
202 (decimal) → Binary: 11001010 → Octal: 312 → Hexadecimal: CA
The bottom panel is different on purpose: bitwise NOT and shifts are only meaningful relative to a declared bit width (flipping every bit of "5" means nothing until you say whether "5" lives in an 8-bit or a 64-bit register), so this tool always requires you to pick one of 8/16/32/64 bits before it will run those operations, and every internal helper that formats or pads a value takes that width as an explicit parameter rather than assuming one. With an 8-bit width:
A = 10110101 (0xB5), B = 01101100 (0x6C) A AND B = 00100100 (0x24) A OR B = 11111101 (0xFD) A XOR B = 11011001 (0xD9) NOT A = 01001010 (0x4A)
Negative values in this panel are stored as two's complement at the selected width — e.g. -1 at 8 bits is 11111111. The "Signed" checkbox controls whether Shift Right sign-extends (arithmetic shift, used for signed values) or zero-fills (logical shift, used for unsigned values) — both are legitimate operations with different uses, so this tool exposes the choice explicitly instead of guessing.
Frequently asked questions
Does this tool support negative numbers?
Yes, in two different ways. The plain base-conversion panel shows negative numbers in sign-magnitude form (e.g. -101 in binary) since it has no declared bit width. The bits/bitwise panel represents negative values in two's complement at whichever width you've selected (8, 16, 32 or 64 bits) — check "Signed" to see the two's-complement decimal interpretation.
How large a number can I convert?
The base-conversion panel uses JavaScript's BigInt, so it handles integers of essentially unlimited size, well beyond 64 bits. The bits/bitwise panel is intentionally capped to your selected width, since operations like NOT and shift are only meaningful relative to a declared bit width.
What happens if I type an invalid digit for the selected base?
The input is rejected with an inline error message instead of being silently truncated or misread — typing 8 while in octal mode, or G in hexadecimal mode, shows exactly what's wrong rather than guessing at a value.
What's the difference between logical and arithmetic shift-right?
A logical shift right always fills the vacated high bits with 0. An arithmetic shift right fills them with the sign bit instead, preserving the sign of a two's-complement negative number. This tool uses arithmetic shift when "Signed" is checked and logical shift otherwise.