5 Basics of Computers · 5.1 Computer basics: number systems, codes, logic, algorithms and spreadsheets

5.1.2 Number systems: binary, octal, hexadecimal and conversion to and from decimal

A number system is fixed by its base (radix): computers work in binary (base 2), and octal (base 8) and hexadecimal (base 16) are short ways of writing binary; any base converts to decimal by adding digit × place value, and decimal converts to any base by repeated division (whole part) and repeated multiplication (fraction).

  • APPSC Paper I
  • Advanced level
  • 6 min read
  • Free

Free PDF

Download this PDF

Enter your email once and the PDF is yours. We send exam updates and free material; you can stop them any time.

In the print window, choose Save as PDF.

Core facts

  • Base (radix) = number of distinct digits. Digits run from 0 to base − 1.
SystemBaseDigitsExample
Binary20, 1101101₂
Octal80 to 755₈
Decimal100 to 945₁₀
Hexadecimal160 to 9, A to F2D₁₆
  • Hex letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
  • Positional value: each place is a power of the base. In binary, from the right: 1, 2, 4, 8, 16, 32, 64, 128, ...; after the point: ½, ¼, ⅛, ...
  • Any base → decimal: multiply each digit by its place value and add.
  • Decimal (whole part) → base b: divide by b repeatedly; read the remainders from bottom to top.
  • Decimal (fraction) → base b: multiply by b repeatedly; read the integer parts from top to bottom.
  • Binary ↔ octal: groups of 3 bits (8 = 2³). Binary ↔ hex: groups of 4 bits (16 = 2⁴). Group from the point outwards; pad with zeros.
  • Octal ↔ hex: go through binary.
  • MSB = most significant (leftmost) bit; LSB = least significant (rightmost) bit.
  • n bits give 2ⁿ patterns; the largest unsigned value is 2ⁿ − 1 (8 bits: 0 to 255).
  • Useful pairs: 2¹⁰ = 1,024; 255 = 11111111₂ = 377₈ = FF₁₆.

Example 1. Convert 45₁₀ to binary. Solution. 45 ÷ 2 = 22 r 1; 22 ÷ 2 = 11 r 0; 11 ÷ 2 = 5 r 1; 5 ÷ 2 = 2 r 1; 2 ÷ 2 = 1 r 0; 1 ÷ 2 = 0 r 1. Read upwards. Answer: 101101₂

Example 2. Convert 11010₂ to decimal. Solution. 16 + 8 + 0 + 2 + 0. Answer: 26

Explained

1. Decimal to octal and hexadecimal.

Example 3. Convert 156₁₀ to octal and to hexadecimal. Solution. Octal: 156 ÷ 8 = 19 r 4; 19 ÷ 8 = 2 r 3; 2 ÷ 8 = 0 r 2 → 234₈. Hex: 156 ÷ 16 = 9 r 12 (C); 9 ÷ 16 = 0 r 9 → 9C₁₆. Check: 2 × 64 + 3 × 8 + 4 = 156; 9 × 16 + 12 = 156. Answer: 234₈ and 9C₁₆

2. Octal and hexadecimal to decimal.

Example 4. Convert 754₈ and 3F7₁₆ to decimal. Solution. 7 × 64 + 5 × 8 + 4 = 448 + 40 + 4 = 492. 3 × 256 + 15 × 16 + 7 = 768 + 240 + 7 = 1,015. Answer: 492 and 1,015

3. Binary to octal and hex by grouping.

Example 5. Write 1101011₂ in octal, hexadecimal and decimal. Solution. Groups of 3 from the right: 1 | 101 | 011 → 153₈. Groups of 4: 110 | 1011 → 6 | B → 6B₁₆. Decimal: 64 + 32 + 8 + 2 + 1 = 107.

Example 6. Convert A5₁₆ to octal. (a) 245 (b) 165 (c) 255 (d) 225 Solution. A5 = 1010 0101 → regroup in threes: 10 | 100 | 101 → 2 | 4 | 5. Answer: (a) 245₈ (A5₁₆ = 245₈ = 165 in decimal; (b) is the decimal value, a trap).

4. Fractions.

Example 7. Convert 0.625₁₀ to binary. Solution. 0.625 × 2 = 1.25 → 1; 0.25 × 2 = 0.5 → 0; 0.5 × 2 = 1.0 → 1. Read downwards. Answer: 0.101₂

Example 8. Convert 25.375₁₀ to binary. Solution. 25 = 11001; 0.375 × 2 = 0.75 → 0; 0.75 × 2 = 1.5 → 1; 0.5 × 2 = 1.0 → 1, so 0.011. Answer: 11001.011₂

Example 9. Convert 1101.11₂ and 1A.8₁₆ to decimal. Solution. 8 + 4 + 1 + ½ + ¼ = 13.75. 1 × 16 + 10 + 8/16 = 26.5. Answer: 13.75 and 26.5

Summary of methods

From → toMethod
Base b → decimalΣ digit × b^position
Decimal → base b÷ b (whole), × b (fraction)
Binary → octal / hexgroups of 3 / 4 bits
Octal ↔ hexvia binary

Deeper

  • Not every decimal fraction ends in binary. 0.1₁₀ = 0.000110011...₂ (the block 0011 repeats), which is why 0.1 + 0.2 is not exactly 0.3 in most programs. A fraction ends in binary only if its denominator (in lowest terms) is a power of 2.
  • Bits needed for a decimal number N: ⌊log₂ N⌋ + 1. 100 needs 7 bits (1100100); 1,000 needs 10 bits.
  • Validity of digits: a numeral is valid in base b only if every digit is less than b. "789" is not an octal number; "1234" needs base 5 or more.
  • Why octal and hex? They compress long bit strings: one hex digit = 4 bits, two hex digits = one byte. Memory addresses, colour codes (#FF0000) and machine code listings use hex.
  • Shifting: appending a 0 to a binary number doubles it (1011 → 10110, 11 → 22); dropping the last bit halves it (whole part only).

Example 10. If 121 in base b equals 49 in decimal, find b. (a) 5 (b) 6 (c) 7 (d) 8 Solution. b² + 2b + 1 = 49, so (b + 1)² = 49 and b = 6. Answer: (b) 6

Example 11. Convert 2F₁₆ to octal. Solution. 2F = 0010 1111 = 101 111 → 57₈. Check: 2 × 16 + 15 = 47 = 5 × 8 + 7. Answer: 57₈

Example 12. Arrange in ascending order: 110011₂, 62₈, 33₁₆. Solution. 110011₂ = 51; 62₈ = 50; 33₁₆ = 51. Answer: 62₈ < 110011₂ = 33₁₆

Common traps

  • ✗ "Read the remainders from top to bottom." ✓ For whole numbers read bottom to top (last remainder is the MSB).
  • ✗ "Read fractional digits bottom to top." ✓ For fractions read the integer parts top to bottom.
  • ✗ "Group bits from the left." ✓ Group from the binary point outwards (right to left for the whole part), padding with zeros.
  • ✗ "Octal uses digits 0 to 8." ✓ Octal uses 0 to 7; hex uses 0 to 9 and A to F.
  • ✗ "Hex F = 16." ✓ F = 15; 10₁₆ = 16.
  • ✗ "8 bits can hold up to 256." ✓ 8 bits give 256 patterns, so the largest unsigned value is 255.
  • ✗ "Every decimal fraction converts exactly." ✓ 0.1₁₀ recurs in binary.

Quick revision

  • Binary 2, octal 8, decimal 10, hex 16; digits 0 to base − 1.
  • A to F = 10 to 15.
  • To decimal: Σ digit × place value.
  • Whole part: ÷ base, remainders bottom up.
  • Fraction: × base, integer parts top down.
  • 3 bits = 1 octal digit; 4 bits = 1 hex digit.
  • n bits → 2ⁿ patterns, max 2ⁿ − 1.
  • 45 = 101101₂ = 55₈ = 2D₁₆.
  • 255 = 11111111₂ = 377₈ = FF₁₆.
  • 0.625 = 0.101₂; 0.1 recurs in binary.

Sources: NCERT Computer Science, Class 11 (encoding schemes and number system); Telugu Akademi / APSCHE, B.Com and B.Sc. first year, Fundamentals of Computers (number systems); V. Rajaraman, Fundamentals of Computers (standard text); M. Morris Mano, Digital Logic and Computer Design (number systems and codes)

Last checked 2026-10-21.

Practise this topic. Questions on Number systems & conversions, with answers explained.

Medha AI writes its own notes and checks them against the sources listed. Medha AI is an independent preparation service. It is not affiliated with, endorsed by or connected to APPSC, TSPSC, MPSC, UPSC or any other commission or government body.