Encoders & Utilities

Number Base Converter

Convert between binary, octal, decimal, and hexadecimal. Supports BigInt and bitwise operations with signed widths.

Bitwise operations

About this tool

Number Base Converter cross-translates an integer between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Type the value in any of the four input fields and the other three update in lockstep. Arbitrary-precision math is built in — paste a 1024-bit hash and you still get an exact answer, no floating-point rounding.

A second panel runs bitwise operations on the same value: AND, OR, XOR, NOT, left shift, right shift, arithmetic right shift. For each operation you pick the integer width (8/16/32/64 bits, signed or unsigned) so two's-complement representations are shown correctly — 0xFF is 255 in u8 but -1 in i8, and the tool labels both. A live binary preview highlights individual bit positions so you can see exactly what flipped.

When to use this tool

  • Reading and writing config flags. Many APIs use bitmask flags; converting 0b10110 to 22 or back is an everyday tax on this style.
  • Debugging hex dumps. A byte showing 0xC0 in memory? That is 192 decimal, 0b11000000 binary.
  • Computing colour values. CSS hex colours, ANSI escape codes, and image-format byte streams all live in hex.
  • Working with file permissions. 0o7550b111101101 — the conversion is the foundation of the Chmod Calculator.

About BigInt and signed widths

JavaScript's native Number loses precision past 2^53. We use BigInt for the value itself, so any integer you can write fits. Signed widths matter for negative numbers: two's complement at 8 bits says 0b10000000 = -128; at 16 bits the same pattern is 32768. The tool always shows you both interpretations so the right one is just a glance away.

Frequently asked questions

Why does 0xFF show as both 255 and -1?

Because the byte pattern is the same — the meaning depends on whether you treat it as unsigned (u8 = 255) or signed two's-complement (i8 = -1). The hardware does not know which; the type system does. We show both interpretations so you can read the value the way your code is expecting it. For wider integers (u32 vs i32) the same logic applies with different break points.

How big a number can the tool handle?

Arbitrary — we use JavaScript BigInt internally, so 4096-bit RSA keys convert just as easily as 8-bit bytes. The bitwise-ops panel needs a width (8 to 64 bits, signed or unsigned) for two's-complement to be defined; beyond 64 bits we treat all values as unsigned and do not show negative interpretations. For cryptographic-scale numbers, decimal/hex/binary all work, but the bitwise table reasonably stops at 64.

What is the prefix convention?

Most ecosystems agree: 0b for binary (Python, JS, Rust), 0o for octal (Python, JS, Rust — the older bare-leading-zero form is deprecated), 0x for hex (universal). Our tool accepts inputs with or without prefixes and always emits results in the conventional prefixed form. C/C++ uses bare-leading-zero for octal (0755), which is a footgun — we never output that form.

Why does shift-right behave differently sometimes?

There are two right-shifts: logical (>>>) fills the high bits with 0 — used for unsigned values. Arithmetic (>>) fills with the sign bit — preserves the sign of negative numbers in two's complement. -8 >> 1 = -4 (arithmetic) but -8 >>> 1 = 2147483644 (logical, 32-bit). The tool exposes both as separate buttons.