Pearson Edexcel GCSE (9-1) Computer Science revision notes
Binary Revision Notes
Review revision notes for Binary in Edexcel Computer Science.
At a glance
revision notes
Resource type
Topic
Binary
Revision notes
Binary Addition and Shifts Revision Notes
Binary Addition Fundamentals
Binary addition follows specific rules: 0+0=0, 0+1=1, 1+0=1, and 1+1=0 with a carry of 1. When a carry (1) is added to 1, it results in 0 with another carry of 1. This process is crucial for representing sums of numbers in computers.
Logical Shifts
A logical shift moves all bits in a binary pattern to the left or right. For a left logical shift, zeros are inserted on the right, and bits on the left are discarded. This effectively multiplies positive numbers by powers of 2. For a right logical shift, zeros are inserted on the left, and bits on the right are discarded, effectively dividing by powers of 2 for positive numbers.
Arithmetic Shifts
Arithmetic shifts are similar to logical shifts but are designed to handle signed numbers more appropriately. A left arithmetic shift is identical to a left logical shift: zeros are inserted on the right. A right arithmetic shift preserves the sign of the number by replicating the original most significant bit (MSB) as bits are shifted right, while discarding bits from the right.
Converting Between Denary and 8-bit Binary Revision Notes
Unsigned 8-bit Binary to Denary Conversion
To convert an 8-bit unsigned binary number to denary, write down the powers of two above each binary digit, starting from 128 (2^7) on the far left, down to 1 (2^0) on the far right. Then, sum the powers of two where there is a '1' in the binary number. For example, 01010101 binary is 64 + 16 + 4 + 1 = 85 denary. The range for unsigned 8-bit binary is 0 to 255, as all eight bits are used to represent magnitude.
Denary to Unsigned 8-bit Binary Conversion
To convert a denary number to an 8-bit unsigned binary, you can use the repeated division by 2 method, collecting the remainders in reverse order. Alternatively, find the largest power of two less than or equal to the denary number, place a '1' in that bit position, subtract it from the denary number, and repeat until the denary number is zero. For example, to convert 200 denary: 128 (1), remainder 72; 64 (1), remainder 8; 32 (0); 16 (0); 8 (1), remainder 0; 4 (0); 2 (0); 1 (0). So, 200 denary is 11001000 binary. All 8 bits must be present.
Signed 8-bit Binary (Two's Complement) to Denary Conversion
For signed 8-bit binary using Two's Complement, the leftmost bit (most significant bit) represents -128 (not +128). The remaining seven bits represent positive powers of two (64, 32, 16, 8, 4, 2, 1). If the MSB is 0, the number is positive, and you convert it like unsigned binary. If the MSB is 1, the number is negative. To convert, sum the values of all bits where '1' appears, with the MSB contributing -128. For example, 10000001 is -128 + 1 = -127. The range for signed 8-bit binary is -128 to +127.
Denary to Signed 8-bit Binary (Two's Complement) Conversion
To convert a positive denary number (up to +127) to Two's Complement, convert it directly to a normal 8-bit binary, ensuring the MSB remains 0. For example, +42 is 00101010. To convert a negative denary number (down to -128), first convert its positive equivalent to 8-bit binary. Then, invert all the bits (0 becomes 1, 1 becomes 0) and add 1 to the result. For example, to convert -5: +5 is 00000101. Invert: 11111010. Add 1: 11111011. This is -5 in Two's Complement.
Understanding Binary Data Representation Revision Notes
Binary as the Foundation of Computing
All data within a computer, regardless of its type (e.g., numbers, text, images, sound, program instructions), is represented using binary. Binary is a base-2 number system, meaning it only uses two symbols: 0 and 1. Each 0 or 1 is known as a 'bit', which is the smallest unit of digital information.
Determining Maximum States with Binary Patterns
The number of distinct items or states that can be represented by a binary pattern depends on its length (number of bits). For a pattern with 'n' bits, the maximum quantity of unique states that can be represented is calculated using the formula 2^n. For example, 4 bits can represent 2^4 = 16 different states (from 0000 to 1111).
Examples of Binary Representation
Numbers are represented directly in binary. Text characters are assigned unique binary codes (e.g., using ASCII or Unicode). Images are broken down into pixels, each with a binary code representing its colour. Sound is sampled, and each sample's amplitude is converted into a binary value. Program instructions are also represented as specific binary codes that the CPU can execute.
Understanding Data Overflow Revision Notes
What is Overflow?
Overflow happens when a calculated or stored value goes beyond the maximum numerical range that can be represented by the available number of bits or the specific data type. It is a common issue in fixed-size data storage, leading to data corruption or incorrect computational results.
Causes and Consequences of Overflow
Overflow is typically caused by performing arithmetic operations that yield a result larger than the maximum representable value (e.g., adding 1 to the largest possible 8-bit integer). The consequences can range from silent data corruption (where an incorrect value is stored without immediate error notification) to program crashes, security vulnerabilities, or unpredictable system behaviour. Programmers must anticipate and handle potential overflow conditions, for instance by using larger data types or by implementing checks to validate computation results.
Example: 8-bit Unsigned Integers
For an 8-bit unsigned integer, the range of representable values is from 0 to 255. If a calculation results in 256, an overflow occurs. What might be stored instead is often 0 (if the most significant bit is simply dropped), which is 256 modulo 256, or some other unexpected value. This demonstrates how an overflow can lead to a significant logical error in a program if not handled properly.
Related topics
Study nearby topics next
Revision hubs
