Free mock test
Number Systems and Codes

Number Systems and Codes

Computer Fundamentals · 3 min read

Computers store everything as binary (0 and 1) because electronic circuits have two stable states, on and off.

SystemBaseDigits used
Binary20, 1
Octal80 to 7
Decimal100 to 9
Hexadecimal160 to 9 and A to F (A = 10, B = 11, C = 12, D = 13, E = 14, F = 15)

Decimal to binary (divide by 2)

Divide repeatedly by 2 and write the remainders from bottom to top.

Example: 45 to binary. 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 upward: 101101.

Check: 32 + 8 + 4 + 1 = 45.

Binary to decimal (place values)

Multiply each bit by a power of 2 and add. Example: 1101 = 8 + 4 + 0 + 1 = 13.

Fractions: the digits after the point have weights 1/2, 1/4, 1/8. So 1101.101 = 13 + 0.5 + 0 + 0.125 = 13.625. To convert a decimal fraction, multiply by 2 and note the integer parts: 0.625 × 2 = 1.25 (1), 0.25 × 2 = 0.5 (0), 0.5 × 2 = 1.0 (1), so 0.625 = 0.101.

Binary, octal and hexadecimal shortcuts

  • Binary to octal: group bits in threes from the right. Binary to hex: group in fours.
  • Example: 10110111 → octal groups 10 | 110 | 111 = 267; hex groups 1011 | 0111 = B7. In decimal both equal 183.
  • Hex to decimal: 2F = 2 × 16 + 15 = 47. Octal to decimal: 17 = 1 × 8 + 7 = 15.

Binary arithmetic

RuleResult
0 + 00
0 + 1 and 1 + 01
1 + 110 (0 carry 1)
1 + 1 + 111 (1 carry 1)

Example: 1011 + 0110 = 10001 (11 + 6 = 17).

Negative numbers

MethodHow
Sign and magnitudeFirst bit is the sign (0 positive, 1 negative).
1's complementInvert every bit.
2's complement1's complement + 1. Used by computers.

Example, -5 in 8 bits: 5 = 00000101 → invert = 11111010 → add 1 = 11111011. An 8-bit two's complement number ranges from -128 to +127.

Character codes

CodeFacts
BCDBinary Coded Decimal. Each decimal digit in 4 bits (8421).
ASCIIAmerican Standard Code for Information Interchange. 7-bit = 128 characters; extended ASCII is 8-bit = 256.
EBCDIC8-bit code used on IBM mainframes.
UnicodeCovers all world languages, including Urdu, Hindi and Kashmiri scripts. UTF-8, UTF-16, UTF-32.
Gray codeOnly one bit changes between successive values.

ASCII values worth knowing: A = 65, Z = 90, a = 97, z = 122, 0 = 48, space = 32. Lower case is 32 more than upper case.

Keep practising

Notes are only half the work. Test yourself with questions and discuss doubts with other aspirants.

Prepared for exam revision from standard computer textbooks, Microsoft documentation and official sources. Features differ between Excel and Word versions (2016, 2019, 2021, 365) so check which version your exam follows. Found a mistake? Tell us.