TestBench.tools

Number Base Converter

Convert between binary, octal, decimal and hexadecimal.

This tool converts a number between binary, octal, decimal and hexadecimal — four synced fields, edit any one and the rest follow live. It uses big-integer math, so long 64-bit register values keep full precision, and invalid digits are flagged with their exact position.

How it works

A positional numeral system with base b weights each digit by a power of b. The same quantity 255 is 11111111 in base 2 (eight ones: 128+64+32+16+8+4+2+1), 377 in base 8, and FF in base 16. Because 16 is 2⁴, each hex digit maps to exactly four binary digits — which is why hex is the standard shorthand for register and memory values.

Worked example

binary  : 11111111
octal   : 377
decimal : 255
hex     : FF

Parameters

ParameterValueNotes
Bases2, 8, 10, 16
Sizearbitrarybig-integer arithmetic
Prefixes0b, 0o, 0xoptional
Grouping_ or space0b1111_1111
Signleading −mathematical, not two's complement

Python implementation

Python
# Same value in four bases (Python int handles arbitrary size)
value = int("FF", 16)
assert bin(value) == "0b11111111"
assert oct(value) == "0o377"
assert value == 255
assert hex(value) == "0xff"

FAQ

How large a number can I convert?

Arbitrarily large — the converter uses big-integer arithmetic, so 64-bit register values and beyond convert without losing precision, unlike converters built on 53-bit floating point.

Are prefixes like 0x, 0b and 0o accepted?

Yes. Each field accepts its own conventional prefix (0x for hex, 0b for binary, 0o for octal), and you can group digits with underscores or spaces — 0b1111_1111 parses fine.

Does it handle negative numbers?

Yes, with a leading minus sign — the sign carries across all four fields. Note this is mathematical negation, not a two's-complement bit pattern; for raw register interpretation use the Two's Complement tool.

Why does editing one field change the other three?

All four fields represent the same value. Whichever field you type into becomes the source; the other three are reformatted from it as soon as the input parses. An invalid digit freezes the others and points at the exact offending position.

Is anything uploaded?

No. All conversion happens locally in your browser.

Related tools