Module 1 Objective 3
Answer: 011101
3. One’s Complement
One’s complement uses a sign bit. In order to calculate the one’s complement of a number:
Eg: -3 in one’s complement using 4 bits. (One’s Complement can only be used to represent)
Sign bit =1 negative), +3 in decimal =011, flip all bits following the sign bit= 1100
Try this: Find the ones complement of -5 using 4 bits (May/June 2013 Question (1)(b)(ii))
4. Two’s Complement
Sign bit= 1, ones complement= 1100, add one to the one’s compliment= 1101
Try this: Find the two’s complement of -5 using 4 bits (May/June 2013 Question (1)(b)(iii))
Try this: Find the 8-bit two’s complement of -21 (May/June 2015 Question (1)(e))
Try this: Calculate the 4-bit two’s complement of -7 (May/June 2014 Question (1) (f))
1
Antonio Johnson “Straight A’s”
CAPE COMPUTER SCIENCE UNIT 1 CLASS (April 2018)
Name:
Date:
Mantissa and Exponent is a format that allows us to store large numbers as well as fractions. It is
very similar to the scientific notation of numbers Eg. 10.67x103 where 10.67 would be the Mantissa,
3 would be the exponent and 10 would be the base.
To convert a number to Mantissa and exponent (taken from Invitations to Computer Science):
Eg. Using 8-bit mantissa, and 8-bit exponent calculate 123 in binary floating point.
12310=0.1111011x107 M E
710=00000111 (exponent)
Try This: Using 1-bit sign, 3-bit exponent, and 5-bit mantissa to calculate the following number
001101011. (May/June 2015 Question (1) (f))
Try This: Using 1-bit sign, 3-bit, and 5-bit exponent, calculate 001110110(May/June 2014 Question
(1) (f))
6. Sign-Magnitude
Sign Magnitude is way of representing a number with the first bit being the sign and the remaining
bits being the number.
(see board)
Modulej 1 Objective 2
8. Logic Gates
2
Antonio Johnson “Straight A’s”
CAPE COMPUTER SCIENCE UNIT 1 CLASS (April 2018)
Name:
Date:
A B A⊕B (A⊕B)’
1
1
1
1
9. Multiplexer
A multiplexer is a device that selects one of multiple input signals and forwards the selected input to
the output line.
Input Lines = 2n
Selector Lines= n
Output Lines= 1
3
Antonio Johnson “Straight A’s”
CAPE COMPUTER SCIENCE UNIT 1 CLASS (April 2018)
Name:
Date:
Try This: Draw a clearly labelled block diagram of a 2:1 multiplexer (May June 2014)
10. Demultiplexer
A demultiplexer is a device that takes a single input line and routes it to one of the several digital
outputs. A demultiplexer has n selector lines, 2n output lines and 1 output lines.
11. Encoder
An encoder is a device
12. Decoder
A decoder converts a code into a set of signals. A decoder has ‘n’ input lines and 2n output lines.
Try This: Draw a clearly labelled block diagram of a 3 to 8 Decoder (May/June 2015 (1)(c))
Module 3
To Define a struct
1. struct structname {
2. int var1;
3. int var2;
4. };
To declare an instance of a struct
1. struct structname struct1, struct2;
To manipulate a struct
1. int main() {
2. struct1.var1 = 10;
3. printf("%d", struct1.var1);
4. return 0;
5. }
To Swap a struct (see board)
4
Antonio Johnson “Straight A’s”
CAPE COMPUTER SCIENCE UNIT 1 CLASS (April 2018)
Name:
Date:
To find the sum of multiples of a number between two boundaries, you must use the % (modulus)
operator. The mod operator gives the remainder of a number and by factor theorem, if a remainder
is 0, then it is a multiple (i.e it is divisible by that number)
5
Antonio Johnson “Straight A’s”
CAPE COMPUTER SCIENCE UNIT 1 CLASS (April 2018)
Name:
Date:
To declare file
FILE *fp