Digital Logic Design
Number System Converter
Binary, decimal, hex, octal — plus BCD, Gray code, ASCII, and two's-complement encoding/decoding — with the repeated-division and positional-expansion steps written out.
About this calculator
Digital hardware speaks several dialects of 'number', and most bugs at the hardware–software boundary are translation errors between them. This converter handles the everyday set with the arithmetic shown, not just the answers.
Base conversion is bidirectional and worked: converting toward binary/octal/hex shows the repeated-division ladder (divide, keep the remainder, read the remainders bottom-up); converting from a base shows the positional expansion (each digit times its place weight). Hex and octal are presented as what they are in practice — compressed spellings of binary, three or four bits per digit.
Beyond plain bases: 8421 BCD, where each DECIMAL digit gets its own nibble (42 is 0100 0010, not 101010 — the distinction that trips every beginner once); reflected Gray code, where consecutive values differ in exactly one bit (g = b ⊕ (b≫1)) — the property that makes rotary encoders and asynchronous interfaces glitch-free; printable ASCII when the value lands in range; and two's complement in explicit 8- or 16-bit widths, encoded by the invert-and-add-one recipe and decoded by sign-weighting the MSB. Width is always stated, because a two's-complement bit pattern means nothing without it: 10101001 is −87 in 8 bits and 169 unsigned — same wires, different contract.
Every representation of the current value is shown side by side, grouped in nibbles for readability, so the converter doubles as a translation table for whatever is sitting in a register right now.
Design notes & common mistakes
- BCD is not binary: 42 is 0100 0010 in BCD (one nibble per decimal digit) but 101010 in binary. Reading one as the other is the classic display-driver bug.
- A two's-complement pattern without a stated width is meaningless — 10101001 is −87 at 8 bits, +169 unsigned, and something else again at 16 bits. State the width everywhere.
- Gray code's one-bit-per-step property is why encoders use it: a mechanical transition can never be misread by more than one count. Converting to binary before doing arithmetic is mandatory — Gray is not positional.
- Hex is a spelling of binary, not a different number system: learn the 16 nibble patterns and register dumps become readable at sight.
Assumptions
- Whole numbers only (fractional-base conversion and IEEE-754 floats are a planned extension).
- Values up to 2⁵³ in base modes; two's complement at the stated widths.
When to use this calculator
Appropriate for
- Converting integers between binary, decimal, hex, and octal, with worked steps
- Encoding/decoding width-explicit two's complement, and converting BCD, Gray code, and printable ASCII
- Teaching positional notation and the invert-and-add-one two's-complement recipe
Not suitable for
- Fractional values, fixed-point, or IEEE-754 floating point, none of which this integer tool handles
- Two's-complement work without a stated width — the same bit pattern means different numbers at different widths
- Extended code pages or Unicode beyond the printable 7-bit ASCII range
What this calculator does not cover
- Integers only — no fractional parts, fixed-point, or IEEE-754 floating point (floats are on the planned-next list as their own tool).
- Two's complement at 8 and 16 bits for encoding (decoding accepts any length up to 32) — wider machine words follow the identical recipe.
- ASCII covers the printable 7-bit range; extended code pages and Unicode are deliberately out of scope.
- As with every calculator on this site: results are preliminary and educational, are not verified for any specific installation, and must be reviewed against the applicable code edition and stamped by a licensed Professional Engineer before real-world use.
Frequently asked questions
Why does the same bit pattern mean different numbers?
Because a pattern has no meaning without its interpretation contract: 10101001 is 169 read unsigned, −87 read as 8-bit two's complement, and invalid as BCD. Hardware moves patterns; the contract lives in your head and your documentation — which is why this tool always states width and encoding.
How does the invert-and-add-one trick work?
Two's complement defines −v as 2ⁿ − v. Inverting every bit of v gives (2ⁿ − 1) − v, so adding 1 lands exactly on 2ⁿ − v. The beauty is that ordinary binary addition then handles signed arithmetic with no special cases.
When would I use Gray code instead of binary?
Whenever a value is sampled while it might be mid-change: rotary encoder disks, asynchronous FIFO pointers crossing clock domains. Consecutive Gray codes differ in one bit, so a mis-sampled transition is off by at most one count instead of, say, 7→8 (0111→1000) being read as 15.
Is BCD still used?
Anywhere digits meet humans without a processor in between: seven-segment displays, digital clocks, meters. One nibble per decimal digit costs storage (1010–1111 unused) but makes display decoding trivial and decimal rounding exact — the same reason financial hardware kept it alive.
References
- Mano, M. M. & Ciletti, M., Digital Design, 6th ed., Ch. 1 (number systems, complements, BCD, Gray)
- Roth, C. H. & Kinney, L., Fundamentals of Logic Design, 7th ed., Ch. 1
Related calculators
Truth Table Generator
Type a Boolean expression (or a minterm list) and get the complete truth table, the canonical Σm and ΠM forms, and an instant read on tautologies and contradictions.
Logic Gate Evaluator
Every standard gate — AND, OR, NOT, NAND, NOR, XOR, XNOR — with its distinctive-shape symbol, live input toggling, full truth table, and what each gate is actually for.
Karnaugh Map Solver (2–5 Variables)
Click cells or enter minterms and watch the K-map group itself: exact Quine–McCluskey minimization drawn as highlighted groups, with the minimal SOP and POS and a proof of equivalence.
Flip-Flop Characteristic & Excitation Tables
SR, JK, D, and T flip-flops as tables: the characteristic table (what Q⁺ will be) and the excitation table (what inputs force a wanted transition), with a live next-state evaluation.
Get the ComputeVerse.ai quick reference
A free engineering quick-reference PDF, plus a note when new calculators launch across the library — one or two emails a month, nothing else.