Content text P1 Notes.pdf
AS COMPUTER SCIENCE P1 2 | PAGE ABDUL REHMAN YASER Chapter 1 Information representation 1.1 Data Representation Binary | Hexa | Denary The basis of any number system consists of: • A base: the number of digits that a number system can use to represent numbers • Place value for each digit: digits in certain positions have a specific value • Denary - Base 10 integer digits • Binary Systems - Base 2 • Possible bits (binary digits): 0 and 1 • All data and characters are represented in binary 128 64 32 16 8 4 2 1 0 0 0 0 0 0 0 0 E.g. 65 in binary is 0100001
AS COMPUTER SCIENCE P1 3 | PAGE ABDUL REHMAN YASER Binary Coded Decimal (BCD) • Binary representation where each positive denary digit is represented by a sequence of 4 bits (nibble) • Only certain digits are converted to BCD, because particular digits represent a digit greater than 9. • Ex. 429 in BCD: • Convert each digit to their binary equivalents • 4 = 0100 | 2 = 0010 |9 = 1001 Concatenate the 3 nibbles (4-bit group) to produce BCD: 0100 0010 1001 • Practical applications • A string of digits on any electronic device displaying numbers (e.g. Calculators) • Accurately measuring decimal fractions • Electronically coding denary numbers Two’s Complement • We can represent a negative number in binary by making the most significant bit (MSB) a sign bit, which indicates whether the number is positive or negative. • Converting negative denary into binary (ex. -42) • Find the binary equivalent of the denary number (ignoring the -ve sign) | 42 = 101010 • Add extra 0 bits before the MSB, to format binary number to 8 bits | 00101010 • Convert binary number to one’s complement (flip the bits) | 11010101 • Convert binary number to two’s complement (add 1) |1010101 + 1 = 11010110 • Converting binary two’s complement into denary (ex. 11010110) • Flip all the bits | 00101001 • Add 1 | 00101010 • Convert binary to denary and put a –ve sign) | -42 • Range is -127 to 128 Hexadecimal Systems - Base 16 • Possible digits: 0 to 9 and A to F, where A to F represent denary digits 10 to 15 • Practical applications: • Defining colors in HTML • Defining Media Access Control (MAC) addresses • Assembly languages and machine code • Debugging via memory dumps • E.g. A5 in Denary = (16×10) + (1×5) = 165 • E.g. 65 in Hexadecimal = 65÷16=4 Remainder 1∴ = 41
AS COMPUTER SCIENCE P1 4 | PAGE ABDUL REHMAN YASER Binary Addition | Subtraction Binary addition and binary subtraction are two fundamental operations in binary arithmetic, which is the mathematical system used in computers and other digital devices. Binary Addition: In binary addition, two binary numbers are added together to produce a third binary number. The process of binary addition is similar to decimal addition, but with only two digits, 0 and 1. Here's an example of how binary addition works: In this example, we are adding two 8-bit binary numbers: 10110110 and 01011101. We start by adding the least significant bits (LSBs), which are the rightmost digits, and then carry over any remainders to the next column if needed. In this case, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 0 with a carry of 1, and so on. Once we have added all the bits, we get the final result of 11000100 in binary, which is equivalent to the decimal value of 196. 1 0 1 1 0 1 1 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 Binary Subtraction: Binary subtraction using the two's complement method is a common technique used in computers to perform subtraction of binary numbers. It works by representing negative numbers using the two's complement representation. Carry out the subtraction 95 – 68 in binary