Przejdź do treści

Cambridge IGCSE Computer Science

IGCSE · Cambridge International (CAIE)Computer Science36 notatek w 10 folderach, 149 KB

36 notatek do nauki dla Cambridge International (CAIE) IGCSE Computer Science, utworzonych przez cookie, w 10 sekcjach zgodnych z tematami kursu.

Notes for Cambridge IGCSE Computer Science (0478), in folders for the syllabus's ten topics in its order: data representation, data transmission, hardware, software, the internet, automated and emerging technologies, algorithm design, programming, databases and Boolean logic. Each folder has one note per sub-topic or small group of them, with worked conversions and calculations, code in the board's pseudocode, and logic truth tables. Follows the syllabus for exams from 2026 to 2028 (version 6).

Co zawiera

Pierwsza notatka

Data representation / Number systems: binary, denary and hexadecimal

Why computers use binary

A computer is built from electronic circuits that have two reliable states, on and off (or high and low voltage). A single circuit therefore stores one binary digit, or bit, which is 0 or 1. Every kind of data a computer handles, whether numbers, text, images, sound or the instructions of a program, has to be converted into patterns of bits before it can be processed. Logic gates work on those bits, and registers inside the processor hold them.

Three number systems

Each system is defined by its base, which is the number of different digits it uses and the value each place is worth a power of.

SystemBaseDigits used
Denary (decimal)100 to 9
Binary20 and 1
Hexadecimal160 to 9 and A to F

In hexadecimal, A to F stand for the values 10 to 15, because a single digit has to be able to hold sixteen different values. The place values in denary are powers of ten (1, 10, 100, 1000), in binary they are powers of two, and in hexadecimal they are powers of sixteen.

For an 8-bit binary number the place values from left to right are:

1286432168421

The leftmost bit is the most significant bit (MSB), because it is worth the most, and the rightmost is the least significant bit (LSB). A 16-bit number extends the same pattern to the left with 32768, 16384, 8192, 4096, 2048, 1024, 512 and 256.

Binary to denary

Write the place values over the bits and add up the values that sit above a 1.

For 01101110:

1286432168421
01101110
64+32+8+4+2=11064 + 32 + 8 + 4 + 2 = 110

Denary to binary

Work down the place values from the largest. If the place value fits into what is left, write 1 and subtract it; otherwise write 0.

For 181:

  1. 128 fits, so write 1. Left: 181−128=53181 - 128 = 53.
  2. 64 does not fit, so write 0.
  3. 32 fits, so write 1. Left: 53−32=2153 - 32 = 21.
  4. 16 fits, so write 1. Left: 21−16=521 - 16 = 5.
  5. 8 does not fit, so write 0.
  6. 4 fits, so write 1. Left: 5−4=15 - 4 = 1.
  7. 2 does not fit, so write 0.
  8. 1 fits, so write 1. Left: 0.

So 181=101101012181 = 10110101_2. Checking by adding back gives 128+32+16+4+1=181128 + 32 + 16 + 4 + 1 = 181.

An alternative is repeated division by 2, writing down the remainders and reading them from the last to the first. Both methods give the same answer, so use whichever is less likely to go wrong for you.

Hexadecimal and binary

Sixteen is 242^4, so one hexadecimal digit corresponds exactly to four bits (a nibble). That makes conversion between the two direct and needs no arithmetic.

DenaryBinaryHexDenaryBinaryHex
000000810008
100011910019
200102101010A
300113111011B
401004121100C
501015131101D
601106141110E
701117151111F

To convert binary to hexadecimal, split the number into groups of four bits starting from the right, and replace each group:

101101012→1011 0101→B 5=B51610110101_2 \rightarrow 1011\ 0101 \rightarrow \text{B}\ 5 = \text{B5}_{16}

To convert hexadecimal to binary, replace each digit with its four bits. For 2F:

2F16→0010 1111=001011112\text{2F}_{16} \rightarrow 0010\ 1111 = 00101111_2

If a binary number does not divide into groups of four, pad it with zeros on the left first. The number 1101101 becomes 0110 1101, which is 6D.

Hexadecimal and denary

Each hexadecimal place is worth a power of 16. For a two-digit number the left digit is worth 16 and the right digit is worth 1.

To convert 6E to denary: 6×16+14×1=96+14=1106 \times 16 + 14 \times 1 = 96 + 14 = 110. This agrees with the binary example above, since 01101110 is 6E.

To convert 181 to hexadecimal, divide by 16: 181÷16=11181 \div 16 = 11 remainder 5. The 11 is B and the remainder is 5, so the answer is B5. A longer number is handled by repeating the division. For 1000: 1000÷16=621000 \div 16 = 62 remainder 8, then 62÷16=362 \div 16 = 3 remainder 14. Reading the remainders from last to first gives 3, E, 8, so 1000=3E8161000 = \text{3E8}_{16}. Checking: 3×256+14×16+8=768+224+8=10003 \times 256 + 14 \times 16 + 8 = 768 + 224 + 8 = 1000.

Conversions in this course use positive whole numbers, with binary numbers of up to 16 bits.

Why hexadecimal is used

Binary is what the machine works in but it is long and easy to misread: a single 16-bit value is sixteen digits. Hexadecimal is a shorter way of writing the same bits, four times shorter, so a person is less likely to make a copying error and can read and compare values more quickly. Because each hex digit maps to exactly four bits, nothing is lost when it is converted back.

Hexadecimal appears wherever people need to read or write binary values:

  • colour codes in web pages and image software, such as #FF8800, where each pair of digits gives the red, green or blue level;
  • MAC addresses, which identify a network card;
  • memory addresses and the contents of memory, shown in debugging tools and in error messages;
  • IPv6 addresses;
  • character codes, such as the Unicode code point U+00E9.

I jeszcze 35: otwórz dowolne z nich z powyższej listy.

Opinie

Nie ma jeszcze pisemnych opinii. Dodaj te notatki do swoich, a możesz być pierwszą osobą, która doda opinię.