Study
IFT-211 route
Unit 1 · Lesson 1 of 3 18 min

Binary Octal and Hexadecimal

One quantity is written in decimal, binary, octal and hexadecimal using positional weights.

A quantity such as fifty-three can be written in decimal, binary, octal or hexadecimal, and digital hardware switches between these representations constantly. Positional weights make every conversion straightforward: each column is worth the number base raised to that column's position.

Analog Against Digital

An analog signal varies smoothly over a continuous range, while a digital signal takes only discrete levels. A dimmer knob sweeps through every brightness in between, whereas a wall switch has only two states: on and off. Digital hardware commits to two voltage bands and calls them 0 and 1, trading continuous detail for strong noise immunity—a slightly degraded 1 is still read reliably as 1.

A binary digit is called a bit, and place value determines each bit's weight. In any base rr, columns to the left of the point carry weights r0,r1,r2,…r^0, r^1, r^2, \dots outward, and columns to the right carry weights r−1,r−2,…r^{-1}, r^{-2}, \dots inward. Binary uses base r=2r = 2, octal uses r=8r = 8, decimal uses r=10r = 10, and hexadecimal uses r=16r = 16 with digits 0–9 followed by A–F for ten through fifteen.

Positional Value of a Number in Base r

N=∑idi ri,1010.112=8+2+0.5+0.25=10.7510N = \sum_{i} d_i \, r^{i}, \qquad 1010.11_2 = 8 + 2 + 0.5 + 0.25 = 10.75_{10}

Multiply each digit by rpositionr^{\text{position}}, where positions run 0,1,2,…0, 1, 2, \dots to the left of the point and −1,−2,…-1, -2, \dots to the right. For example, 1010.112=8+2+0.5+0.25=10.75101010.11_2 = 8 + 2 + 0.5 + 0.25 = 10.75_{10}. Moving one column to the right always divides the column weight by the base, just as in decimal.

Converting Between Bases

Repeated division by the target base converts integer parts, whereas repeated multiplication converts fractional parts. To convert 25 to binary, divide repeatedly by 2 and record each remainder: 25→12 r1→6 r0→3 r0→1 r1→0 r125 \to 12\text{ r}1 \to 6\text{ r}0 \to 3\text{ r}0 \to 1\text{ r}1 \to 0\text{ r}1, then read the remainders from last to first as 11001211001_2. The first remainder is the least significant bit (LSB), and the last is the most significant bit (MSB).

For 0.6250.625, multiply repeatedly by 2 and keep each integer part: 0.625→1.25→0.5→1.00.625 \to 1.25 \to 0.5 \to 1.0, read from top to bottom as 0.10120.101_2. Integer and fractional parts convert separately and rejoin at the point.

Octal and hexadecimal act as compact shorthands for groups of three and four bits. Because 8=238 = 2^3, each octal digit corresponds to three bits: group outward from the binary point, pad outer groups with zeros if needed, and translate each group.

Because 16=2416 = 2^4, each hexadecimal digit corresponds to four bits in the same way. Thus 10110101210110101_2 groups as 010 110 101=2658010\ 110\ 101 = 265_8 and as 1011 0101=B5161011\ 0101 = \text{B5}_{16}, while 2F162\text{F}_{16} expands back to 0010 111120010\ 1111_2.

Common hardware units group bits into standard sizes: a nibble is 4 bits (one hexadecimal digit), a byte is 8 bits, and a word is a processor's natural data width (often 16, 32 or 64 bits). Within any binary word, the MSB is the leftmost bit carrying the largest weight (worth 128 in an 8-bit unsigned byte), while the LSB is the rightmost bit carrying weight 1 (determining whether an integer is odd or even).

Fractions that terminate neatly in decimal do not always terminate in binary. Doubling 0.1100.1_{10} gives 0.2,0.4,0.8,1.6,1.2,0.4,…0.2, 0.4, 0.8, 1.6, 1.2, 0.4, \dots, producing the repeating binary fraction 0.000110011…20.000110011\ldots_2. Because computers store a finite number of bits, floating-point arithmetic holds an approximation very close to 0.10.1 rather than the exact fraction—which is why 0.1+0.20.1 + 0.2 may not equal 0.30.3 exactly in code.

Only decimal fractions whose denominator is a power of 2 (such as 0.50.5, 0.250.25 or 0.6250.625) terminate in binary.

When real-world signals enter a computer, sampling converts continuous waves into digital data by measuring the signal at regular intervals (for example, 44,100 times per second for audio) and quantising each sample into binary bits. By Nyquist's sampling theorem, you must sample at more than twice the highest frequency in the signal, or high frequencies fold down into distorted aliases.

Once inside digital circuits, noise margins keep bits reliable: for instance, 0–0.8 V may be read as 0 and 2–5 V as 1, leaving an unused middle band so small electrical interference cannot flip a logic level.

Worked example

Worked Example: 110101.101₂ to decimal and hexadecimal

  1. 1
    Step 1

    Expand the integer part by positional weights: 1×32+1×16+0×8+1×4+0×2+1×1=531\times 32 + 1\times 16 + 0\times 8 + 1\times 4 + 0\times 2 + 1\times 1 = 53.

10110101 binary 10 110 101 groups of 3: 265 octal 1011 0101 groups of 4: B5 hex
Group binary digits outward from the point: sets of three translate to octal, and sets of four translate to hexadecimal.

Pause & think

Convert 47.4847.4_8 to binary and to decimal. Which conversion requires positional weights, and which relies purely on grouping?

Positional weights evaluate any base in decimal, repeated division and multiplication convert between bases, and 3-bit or 4-bit grouping bridges binary with octal and hexadecimal.

📌 If you remember nothing else…

  • Digital signals use discrete voltage levels with noise margins, and each column in base rr has weight rpositionr^{\text{position}}.
  • Integer parts convert via repeated division by the target base, while fractional parts convert via repeated multiplication.
  • Octal groups 3 bits per digit and hexadecimal groups 4 bits per digit outward from the binary point.
  • For example, 101101012=2658=B51610110101_2 = 265_8 = \text{B5}_{16}, and 110101.1012=53.62510=35.A16110101.101_2 = 53.625_{10} = 35.\text{A}_{16}.

Quick check

Did it land?

1. What is decimal 25 in binary?
2. What is 10110101 in hexadecimal?

Spotted a mistake?