ข้ามไปยังเนื้อหา
cookie

Cambridge A level Computer Science

A-Level · Cambridge International (CAIE)Computer Science20 โน้ต ใน 5 โฟลเดอร์, 72 KB

โน้ตทบทวน 20 รายการสำหรับ Cambridge International (CAIE) A-Level Computer Science สร้างโดย cookie แบ่งเป็น 5 ส่วนตามหัวข้อของหลักสูตร

Revision notes for Cambridge International AS and A Level Computer Science (9618), in five folders for the syllabus's content areas, in the syllabus's order, with one note for each topic. Follows the syllabus for 2027 exams (version 3). The fifth folder and the recursion, paradigm and abstract data type notes are A Level content; delete them if you take AS only.

มีอะไรอยู่ข้างใน

โน้ตรายการแรก

Data representation and communication / Number systems and binary arithmetic

Computers store everything as patterns of bits, so the same pattern can be read in several number bases. Denary is base 10, binary is base 2 and hexadecimal is base 16. Each position in a binary number is a power of two, so 13 in binary is 1101, which is 8 + 4 + 1. To write a denary number in eight bits, fill the powers of two from the largest down, placing a 1 where the value fits and a 0 where it does not. So 13 becomes 00001101.

Hexadecimal is used because one hex digit stands for exactly four bits. Split a binary number into groups of four from the right and convert each group. The binary number 10110010 splits into 1011 and 0010, which are B and 2, so the hex form is B2. Going the other way, F is 1111 and 1 is 0001, so 1F is 00011111, which is 16 + 15 = 31 in denary. Hex appears where a compact form of binary helps a person read it, such as memory addresses and colour codes.

Binary Coded Decimal (BCD) is a different idea. Each denary digit is stored as its own four-bit binary number, so 45 becomes 0100 0101. BCD wastes some combinations (1010 to 1111 are never used) but makes it simple to convert the value for display, which is why it appears in systems that show or enter decimal digits, such as some clocks and calculators.

Negative numbers

Two's complement is the usual way to store negative integers. For a positive number, write it in binary with the leftmost bit as 0. To find the negative, invert every bit (this is one's complement) and then add 1. For 45, which is 00101101, inverting gives 11010010 and adding 1 gives 11010011. The leftmost bit is now 1, which marks the number as negative. In eight bits, the range runs from -128 to 127. The pattern 11111111 is -1, because adding 1 to it gives 00000000 once the carry out of the leftmost bit is ignored.

One's complement is the simpler idea of inverting every bit, with no addition. It is less used because it has two representations of zero, one of them 11111111 and the other 00000000, which makes arithmetic awkward.

Binary addition and overflow

Binary addition works like denary addition with carries, but a carry happens whenever two 1s meet. Add 01101001 (105) and 00110110 (54): the sum is 10011111, which is 128 + 16 + 8 + 4 + 2 + 1 = 159. That is correct and needs no extra bit.

Overflow happens when a result needs more bits than the store holds. With eight bits, 11111111 plus 00000001 gives 100000000. The leftmost carry is lost, so the stored result is 00000000 and the answer is wrong for an unsigned number. Two positive two's complement numbers can overflow into the sign bit in the same way: adding 01000000 and 01000000 gives 10000000, which reads as -128 rather than 128. Overflow is therefore a sign that the result has run out of room, and the program has to detect it.

Checking your work

Convert each binary result back to denary before trusting it. Most mistakes in this topic come from losing track of the bit width. Write the number of bits beside every answer, because 1101 and 00001101 are the same value but not the same stored pattern once a sign is involved.

และอีก 19 รายการ: เปิดรายการใดก็ได้จากรายการด้านบน

รีวิว

ยังไม่มีรีวิวที่เขียนไว้ เพิ่มโน้ตเหล่านี้ลงในของคุณ แล้วคุณจะเป็นคนแรกที่เขียนรีวิว