Numbering Systems
Every digital instrument — data logger, panel meter, PLC, DMM — speaks in 1s and 0s. This lab teaches the four number systems, and the codes built on them, that let you read what the instrument is saying: work the theory, then prove it to yourself in the calculators. Each tool shows the entire chain of work, the way you'd write it by hand.
Digital versus Analog
Analog quantities vary continuously: temperature, pressure, flow, velocity, voltage. Nearly everything a transducer measures in the field is analog. Digital systems, by contrast, deal only in discrete states — ON and OFF, typically +5 V and 0 V — which we write as 1 and 0. A digital value is just a string of those two symbols.
Why digitize a world that is naturally analog? Because two clean voltage levels are cheap to generate, immune to small noise, and easy to store and transmit. A little noise riding on an analog signal is part of the measurement forever; the same noise on a digital line still reads unambiguously as HIGH or LOW. That is why a data logger converts each sensor's analog voltage through an analog-to-digital converter (ADC) before anything else happens — and why the rest of this lab is about reading the binary words an ADC produces.
The demo below is the front end of every digital instrument you will ever use. An analog waveform is sampled at regular intervals, and each sample is quantized to the nearest of 2n levels, where n is the converter's resolution in bits. Drag the sliders: more samples track the wave more faithfully in time; more bits resolve it more finely in amplitude.
ADC Sampling Bench
sample · quantize · encodeThe staircase is what the computer "sees." Each step is one sample; its height is the code the ADC stored. An 8-bit converter has 256 levels; a 12-bit converter, 4096; a 16-bit converter, 65 536. Resolution costs money — knowing how many bits you need is an instrumentation decision.
How an ADC actually works
Every ADC, whatever its price tag, performs the same three jobs in sequence:
1 — Sample and hold. A switch briefly connects the input to a small capacitor, then disconnects. The capacitor "freezes" the voltage so it cannot change while it is being measured — like photographing a moving dial instead of trying to read it live.
2 — Quantize. The frozen voltage is compared against a ruler of 2n evenly spaced levels and rounded to the nearest one. The spacing of that ruler is the step size, also called 1 LSB — because moving up exactly one level changes only the last bit of the code.
3 — Encode. The chosen level number is output as an n-bit binary code — exactly the weighted binary of the sections below. From here on, the measurement is just a number.
Step size (1 LSB) = full-scale range ÷ 2n. A 0–5 V input on an 8-bit ADC: 5 ÷ 256 = 19.5 mV per step. The rounding in step 2 makes every reading uncertain by up to ±½ LSB — that error is designed in, and the only cure is more bits. (Watch the readout under the graph recompute this as you move the resolution slider.)
Timing matters as much as resolution. The sample rate must be at least twice the highest frequency in the signal — the Nyquist rate — or the samples tell a false story: a fast wiggle masquerades as a slow one, an effect called aliasing. You can see the beginnings of it in the demo: pull the samples slider down to 4 and the staircase invents a wave shape that isn't there. Real instruments sample several times faster than the minimum and low-pass filter the input first.
Four Ways to Build One
architecturesDifferent instruments make the "which level?" decision differently. The trade is always speed against precision against cost — and each architecture has a home turf you will recognize.
| Type | How it decides | Speed | You'll find it in |
|---|---|---|---|
| Flash | One comparator per level — all 2ⁿ−1 of them vote at once | Fastest (ns) | Oscilloscopes, video capture |
| SAR | Binary search: tests one bit per clock tick, MSB first | Fast (µs) | Data loggers, DAQ boards, control loops |
| Dual-slope | Integrates the input for a fixed time, then times how long a reference takes to discharge the integrator | Slow (ms) | Bench DMMs — integrating over a mains cycle rejects 50/60 Hz hum |
| Sigma-delta | Oversamples with a 1-bit converter, then averages digitally | Slow–medium | Load cells, thermocouple modules, audio |
The successive-approximation (SAR) converter is worth opening up, because it runs on this lab's math. Inside is a small DAC and one comparator, playing "higher or lower": starting at the MSB, the logic switches in one binary weight at a time, keeps the bit if the guess is still at or below the input, and clears it if the guess overshoots. After n clock ticks the code is finished. It is the largest-power-of-2 conversion method, executed in silicon.
Inside a SAR ADC — step through one conversion
4-bit · 0–5 VPositional Notation and Weighting Factors
Decimal feels natural only because you have used it since childhood; structurally, it is nothing special. In any positional number system each digit position carries a weighting factor equal to the base raised to the position number, counting from 0 at the right. In base 10 the weights are …10³, 10², 10¹, 10⁰ — thousands, hundreds, tens, ones.
Read 4623 as a machine would: 4×1000 + 6×100 + 2×10 + 3×1. The digit tells you how many; the position tells you of what. Everything in this lab follows from that single idea — swap the 10 for a 2, an 8, or a 16 and the machinery is identical.
Multiply each digit by its weighting factor (baseposition) and add the products. The least-significant digit of any base always has weight base⁰ = 1.
The master converter below is built on that idea. Enter a number in any one system — decimal included — and the table shows it in every one of them, BCD and ASCII codes included, each row with its complete worked breakdown: a weighted sum toward decimal, successive division or bit grouping away from it. Work it in any direction, and come back to it after the octal and hex sections.
Master Converter — every base at once
any directionPick the base you're starting in, type the number, and read the rest. Every row carries its own work — the same procedures the sections below teach by hand.
Binary — Base 2
Digital electronics settled on binary because its two digits, 0 and 1, map directly onto two transistor states: 0 V and +5 V. Each binary digit is a bit. Four bits make a nibble, eight make a byte — the standard width of a memory location and of most basic ADC outputs.
Binary weights are the powers of 2: …128, 64, 32, 16, 8, 4, 2, 1. Memorize the first eight — you will use them constantly. To evaluate a binary number, add the weights wherever a 1 appears: 0101 0110₂ = 64 + 16 + 4 + 2 = 86₁₀. (The master converter above starts loaded with exactly that number — its DEC row shows this expansion.)
The weights continue past the radix point by successive division: each step down the ladder divides by 2. That ladder is also the cleanest proof that 2⁰ = 1 — it is the rung between 2¹ = 2 and 2⁻¹ = 0.5.
The Powers-of-2 Ladder
2⁻⁴ … 2⁷| Power | Weight |
|---|
Positions left of the point: 2⁰ up through 2⁷ for one byte. Positions right of the point: 2⁻¹ = 0.5, 2⁻² = 0.25, … — seldom used in hardware, but they complete the pattern.
The rightmost bit is the LSB (least significant bit, weight 2⁰); the leftmost is the MSB (most significant bit). Answers are normally padded with leading zeros to a full 4-, 8-, 16-, or 32-bit width — padding never changes the value.
Successive Division — Decimal to Any Base
Going toward decimal, you multiply by weights. Going away from decimal, the universal procedure is successive division: divide the decimal number by the target base, keep the whole-number quotient, and write down the remainder. Divide that quotient by the base again. Repeat until the quotient reaches 0.
The remainders, read in reverse order, are the answer. The first remainder is the least significant digit — it is what is left over after everything divisible by the base has been carried upward — and the last remainder is the most significant digit. Reversing them is the classic exam mistake; the calculator below labels both ends so the habit sticks.
Divide by the base repeatedly until the quotient is 0. First remainder = LSD, last remainder = MSD. Read the remainders bottom-up. Works for base 2, 8, 16 — any base at all.
There is also a calculator-friendly way to pull out each remainder. Your calculator answers 61 ÷ 2 with 30.5 — a decimal, not a quotient-and-remainder pair. No problem: the whole part (30) is the next quotient, and the fractional part times the base recovers the remainder: .5 × 2 = 1. It works in every base: 498 ÷ 16 = 31.125, and .125 × 16 = 2, so the low digit is 2; then 31 ÷ 16 = 1.9375, and .9375 × 16 = 15 = F. The machine below can annotate every line with this shortcut — leave it on until it's second nature.
Calculator shows: whole part . fraction → remainder = fraction × base. Keep the whole part as the next quotient, convert the fraction, repeat until the display reads 0.
Successive-Division Machine
step throughOctal — Base 8
Octal uses the eight digits 0–7, and it exists for one reason: 8 = 2³, so one octal digit is exactly three bits. Long binary strings become short, readable octal with no arithmetic at all — just grouping. Octal shows up in legacy minicomputer documentation, Unix file permissions (chmod 755), and some older PLC addressing schemes.
Counting in octal: 0, 1, 2, 3, 4, 5, 6, 7 — and then, with 8 and 9 unavailable, the position resets and carries: 10, 11, 12, … 17, 20. Octal 10 is decimal 8.
Three conversions, three tools. Octal → decimal: weighted sum with powers of 8 (the master converter above). Decimal → octal: successive division by 8 (the machine above). Octal ↔ binary: pure regrouping — the Bit Grouping Lab below draws the braces for you.
Binary → octal: starting at the LSB, mark off groups of 3 bits (pad the left group with leading zeros) and write each group's octal digit. Octal → binary: replace each octal digit with its 3 bits.
Hexadecimal — Base 16
Hexadecimal is the working language of modern digital instrumentation. Since 16 = 2⁴, one hex digit is exactly four bits — one nibble — so a byte is always two hex characters, a 16-bit register four, a 32-bit word eight. Memory addresses, Modbus register maps, CAN identifiers, and raw sensor payloads are all documented in hex.
Sixteen digit symbols are needed and only ten numerals exist, so the alphabet fills in: A=10, B=11, C=12, D=13, E=14, F=15. A hex value is flagged with a subscript 16, a trailing H (2A6H), or the programmer's prefix 0x (0x2A6) — all three mean the same thing.
The same three routes apply. Hex → decimal: weighted sum with powers of 16 (2A6₁₆ = 2×256 + 10×16 + 6×1 = 678₁₀). Decimal → hex: successive division by 16 — remainders of 10 through 15 are written A through F. Hex ↔ binary: regroup by fours. Many students find two-step routes through binary (hex → binary → decimal) easier than direct arithmetic; both are valid.
Binary → hex: from the LSB, mark off groups of 4 bits and write each group's hex digit. Hex → binary: each hex digit expands to its 4 bits. A byte is two nibbles: 0111 0000₂ = 70₁₆.
Bit Grouping Lab
The regrouping conversions deserve their own bench because they are the ones you will do most often at an instrument. The lab pads the left group for you and dims the padding, so you can see it never changes the value.
Grouping Visualizer — binary ↔ octal / hex
3s and 4sBinary & Hex Arithmetic
Digital systems don't just store numbers — they compute with them, and the arithmetic happens in the machine's own bases. Column addition in base 2 or base 16 works exactly like the addition you learned in grade school; the only thing that changes is when you carry. A column carries when its sum reaches the base — not when it reaches ten.
Binary addition needs only four facts: 0+0 = 0, 0+1 = 1, 1+1 = 0 carry 1 (because two is 10₂), and — once carries start rippling — 1+1+1 = 1 carry 1 (three is 11₂). Work right to left, exactly as on paper. That ripple of carries is not just a hand method: it is literally how a ripple-carry adder circuit computes, one full-adder per column, built from logic gates.
Hex addition: add the digit values as ordinary decimal numbers; if a column reaches 16, subtract 16 and carry 1. So A + 9 is 10 + 9 = 19 → write 3, carry 1. You will use this constantly in the field — stepping through a register map (base address 4000H + offset 1AH = 401AH) or checking a serial-frame checksum, which in many ASCII protocols is simply the hex sum of the message bytes.
Adding: if a column's sum reaches b, write (sum − b) and carry 1 into the next column. Subtracting: if the top digit is too small, borrow 1 from the next column — it arrives worth b in this one.
Subtraction with borrows follows the same column discipline — 0 − 1 borrows a 2 from the next binary column, and a hex borrow arrives worth 16. But long borrow chains are where people (and early computer designers) slip, which is exactly why real hardware subtracts by adding the two's complement instead — the subject of the next section. Learn the borrow method here for hand work and exams; then watch the next section make it unnecessary in silicon.
Column Arithmetic Machine
carries & borrowsTwo's Complement — Signed Binary
Everything so far has been unsigned — fine for a tank level or a memory address, but instrumentation is full of quantities that swing negative: temperatures below zero, bipolar inputs (±10 V), reverse flow, the error term in a control loop. A binary word has no minus key; the sign has to live in the bits themselves.
The industry's answer is two's complement. Keep every weighting factor from the binary section except one: in an n-bit word, the MSB's weight turns negative — for 8 bits, −128 instead of +128. Any code with the MSB clear is an ordinary positive number; any code with the MSB set is negative. The scheme gives one unambiguous zero, and — the reason it won — the same adder hardware works for both signs, so subtraction comes free.
You rarely evaluate that negative weight directly. To negate any value there is a two-step recipe: invert every bit, then add 1. Run it on +73 and you get −73; run it again and you are back at +73. Subtraction then disappears as a separate operation: A − B is computed as A + (−B), and any carry out of the MSB is simply discarded.
Negate = invert all bits, add 1. In an n-bit word the MSB weighs −2n−1; the range is −2n−1 … +2n−1−1. MSB = 1 always means negative.
| Width | Range | −1 looks like |
|---|---|---|
| 4-bit | −8 … +7 | 1111 |
| 8-bit | −128 … +127 | 1111 1111 |
| 16-bit | −32 768 … +32 767 | 1111 1111 1111 1111 |
Where you will meet it: a bipolar ADC digitizing ±10 V hands you two's-complement codes; a digital temperature sensor reporting −40 °C sends a two's-complement word; every processor's subtract instruction is invert-add-1 under the hood. When a datasheet says signed 16-bit, this is what it means — and note the asymmetry: there is one more negative value than positive, so −128 exists in 8 bits but +128 does not.
Two's-Complement Lab
signed numbersFeel the Sign Bit — flip an 8-bit word
unsigned vs. signedThe same eight bits, two readings. Click bits on and off: the two interpretations agree completely — until the red sign bit goes high, where unsigned keeps counting up while two's complement dives to −128 and climbs back toward −1.
Binary-Coded Decimal
BCD is not a number system — it is a code. Each decimal digit is written as its own 4-bit group: 496 becomes 0100 1001 0110. No division, no weighting across groups; digit by digit, done. That makes BCD ideal for driving numeric displays — digital voltmeters, panel thermometers, clocks — where each nibble feeds one seven-segment digit directly.
The cost is efficiency: pure binary stores 496 in 9 bits, BCD needs 12. And only nibbles 0000–1001 are legal. The six patterns 1010 through 1111 (10–15) are invalid BCD — if a display driver receives one, something upstream is broken. The decoder below flags them — a classic display-driver failure mode.
BCD Encoder / Decoder
digit by digitThe Systems Side by Side
Counting is where the systems' personalities show. Watch where each column "rolls over": binary at every power of 2, octal after 7, hex after F, and BCD — the impostor — after 9, because it mirrors decimal digit-for-digit. Notice too that BCD and binary agree perfectly from 0 through 9 and then permanently part ways at 10.
Counting Table
roll-overs| Decimal | Binary | Octal | Hex | BCD |
|---|
The ASCII Code
Numbers are not enough — instruments must also move alphanumeric data: unit labels, part numbers, error messages, commands. The industry's I/O code is ASCII (American Standard Code for Information Interchange): 7 bits per character, 2⁷ = 128 combinations covering letters, numerals, punctuation, and 33 control characters. In memory each code is normally padded to 8 bits with a leading 0 (the eighth bit is sometimes a parity bit instead).
ASCII is everywhere in instrumentation. A bench meter answering a SCPI query over RS-232 or USB replies in ASCII text; when a DMM sends MEAS:VOLT? results back as +1.2345E+00, every one of those characters is a 7-bit code from this table. Reading a raw serial capture in hex and recognizing 0x41–0x5A as capital letters is a genuinely useful field skill.
A code is assembled from the table as column bits then row bits: the 3-bit column group is the MSB side, the 4-bit row group the LSB side. G sits in column 100, row 0111 → 100 0111. Click any cell to see the assembly; note the elegant structure — 0–9 are 011 0000 through 011 1001 (hex 30–39), and upper/lowercase letters differ by exactly one bit (bit 5).
ASCII Table — click a character
7-bit codeText → ASCII Encoder
SCPI-friendly| Char | 7-bit | 8-bit (padded) | Hex | Dec | Oct |
|---|
Applications in Instrumentation
Which system you use depends on how the data were produced and where they are going. An ADC hands you raw binary; a technician reads it back as hex because bytes chunk cleanly into two characters; a BCD word drives a numeric display; ASCII carries text over a serial link. The classic teaching example ties them all together: a monitoring computer watching alarm contacts.
A geothermal plant monitors the temperature (T) and pressure (P) of four storage tanks, A through D. Each sensor drives one bit of an 8-bit status word — 1 means danger limit exceeded, 0 means OK. The computer reads the word; the technician must interpret it. Flip the sensors below, or load one of the preset fault codes, and read the same status word all four ways.
Tank-Farm Alarm Monitor
8-bit status wordTwo more patterns worth carrying with you. BCD at the display: a three-digit panel thermometer needs 12 bits, four per digit — 147°F arrives as 0001 0100 0111. Hex at the memory map: a 20-bit address bus reaches 2²⁰ ≈ one million locations, written as exactly five hex characters, 00000H–FFFFFH. Every register map and datasheet you read from here on assumes you can move between these representations without friction.
Practice
Randomly generated problems in the classic textbook forms. Answer in the box — spacing and leading zeros don't matter, hex is case-insensitive — then check yourself. Every problem can show its full worked solution using the same layouts as the calculators above.
Problem Generator
17 problem typesReference
Powers of 8 and 16
weights| n | 8ⁿ | 16ⁿ | 2ⁿ |
|---|
Glossary
- Analog
- A quantity or system that varies continuously — temperature, pressure, voltage. Infinitely many in-between values.
- Digital
- A quantity or system restricted to discrete states; in electronics, the two states HIGH and LOW, written 1 and 0.
- ADC / DAC
- Analog-to-digital converter / digital-to-analog converter. The ADC quantizes a sensor voltage into an n-bit binary code; the DAC reverses the process.
- Base (radix)
- The number of distinct digit symbols in a positional number system, and the multiplier between adjacent position weights.
- Bit · Nibble · Byte · Word
- One binary digit · four bits · eight bits · the natural data width of a processor (16, 32, or 64 bits today).
- Weighting factor
- The value of a digit position: base raised to the position number. The rightmost integer position of every system weighs base⁰ = 1.
- LSB / MSB (LSD / MSD)
- Least / most significant bit of a binary string — the lowest and highest weighted positions. LSD/MSD are the digit equivalents in any base.
- Successive division
- The decimal-to-any-base procedure: divide by the base until the quotient is zero and read the remainders in reverse.
- BCD
- Binary-coded decimal: each decimal digit encoded independently as 4 bits. Nibbles 1010–1111 are invalid. Used to drive numeric displays.
- ASCII
- The 7-bit alphanumeric I/O code (128 characters) used to move text into, out of, and between digital systems.
- Alphanumeric
- Data containing letters and symbols as well as numerals.
- Quantization / resolution
- Rounding a sampled analog value to the nearest of 2ⁿ levels; n bits of resolution divide the input range into 2ⁿ steps of (full scale ÷ 2ⁿ) each, with a built-in uncertainty of ±½ step.
- Nyquist rate
- The minimum sampling rate — twice the highest frequency present in the signal — below which samples alias into false, slower waveforms.
- SAR (successive approximation)
- The workhorse mid-speed ADC architecture: an internal DAC binary-searches the input one bit per clock, MSB first, using the binary weighting factors directly.
- Carry / borrow
- The overflow between adjacent columns in positional arithmetic. A column carries 1 outward when its sum reaches the base; a borrow taken from the next column arrives worth one whole base (2 in binary, 16 in hex).
- Two's complement
- The standard signed-binary code: the MSB carries weight −2ⁿ⁻¹, so an 8-bit word spans −128 … +127. Negate any value by inverting every bit and adding 1.
- Parity bit
- An extra bit appended to a code word (often ASCII's eighth bit) making the count of 1s even or odd, to detect single-bit transmission errors.
An interactive study lab for number systems and digital codes. Every calculation runs locally in your browser — nothing leaves your device. A working aid for coursework and the field, not a substitute for either.