KS5H446 1.4.1 and 1.4.3 38 min read 10 question quiz 20 exam marks

Data Types, Number Systems and Boolean Algebra

Two's complement, floating point, bitwise operations, character sets, and Boolean algebra including De Morgan's laws and Karnaugh maps.

Number representation

Two's complement

The standard representation for signed integers. The most significant bit has a negative place value.

For 8 bits: -128, 64, 32, 16, 8, 4, 2, 1

11101100 = -128 + 64 + 32 + 8 + 4 = -20

To negate a number: invert every bit, then add one.

20 = 00010100 invert 11101011 add 1 11101100 = -20

Range for n bits: -2^(n-1)^ to 2^(n-1)^ - 1. For 8 bits that is -128 to 127.

Subtraction becomes addition of the negative, which is why hardware needs only an adder.

Floating point

A number is stored as a mantissa and an exponent, both in two's complement.

value = mantissa x 2^exponent

Normalisation maximises precision by ensuring the mantissa begins with 01 for a positive number or 10 for a negative one, so no significant bits are wasted on leading duplicates.

Example with a 6 bit mantissa and a 4 bit exponent:

0.1101 0 0011 -> mantissa 0.1101, exponent 3 -> 110.1 = 6.5

The trade off. For a fixed total number of bits, more mantissa bits give greater precision and more exponent bits give greater range. You cannot increase both.

Fixed point places the binary point at a set position. It is faster and always has the same absolute accuracy, but a far smaller range.

Bitwise operations

OperationEffect
ANDMasking: x AND 00001111 keeps only the low nibble
ORSetting bits: x OR 10000000 forces the top bit on
XORToggling, and a simple reversible cipher, since (x XOR k) XOR k = x
Left shiftMultiplies by 2 per place
Right shiftDivides by 2 per place, losing the bits shifted out

Character sets

ASCII uses 7 bits for 128 characters. Unicode uses 16 or more bits for over a million, covering all major writing systems, at the cost of larger files.

Converting binary 01011010 to denary using place valuesAn eight bit binary number laid out under its place values. The place values from left to right are 128, 64, 32, 16, 8, 4, 2 and 1, each half the one to its left. The bits are 0, 1, 0, 1, 1, 0, 1, 0. Where a bit is 1 the column contributes its place value, so the contributions are 0, 64, 0, 16, 8, 0, 2 and 0. Adding the contributions gives 64 plus 16 plus 8 plus 2, which is 90. So binary 01011010 is 90 in denary.1280064164320016116818400212100placebitworth64 + 16 + 8 + 2 = 90so 01011010 in binary is 90 in denary
Write the place values above the bits every single time. It costs five seconds and removes almost every conversion error.

Number base converter

Convert between denary, binary and hexadecimal, with every step of the working written out. This tool needs JavaScript, so turn it on to use it. Everything you need to answer the exam question is explained in the text above.

Two's complement: the left bit is worth minus 128, and how to find -5 from +5Two's complement stores negative numbers in binary. In eight bits the place values are minus 128, 64, 32, 16, 8, 4, 2 and 1, so the leftmost bit is worth minus 128 instead of plus 128. The bits 1111 1011 are minus 128 plus 64 plus 32 plus 16 plus 8 plus 2 plus 1, which is minus 5. To find minus 5 from plus 5, write 5 as 0000 0101, flip every bit to get 1111 1010, then add 1 to get 1111 1011. Eight bits give 256 values from minus 128 to plus 127, one more negative number than positive because there is no plus 128.Eight bits, with the left bit worth -128111111011-1286432168421-128 + 64 + 32 + 16 + 8 + 2 + 1 = -5Finding -5 from +52Write +500000101Flip every bit11111010Add 111111011The range3-12801278 bits give256 valuesone more negative thanpositive: there is no +128
  1. The leftmost bit has a negative place value, -128. Add up the columns that hold a 1.
  2. To negate a number: write it in binary, flip every bit, then add 1.
  3. Eight bits hold -128 to 127. There is one more negative number than positive.
The left bit is the sign bit: 1 means negative. Check an answer by adding the column values back up.
6.5 stored in floating point as the mantissa 01101000 and the exponent 0011A floating point number has two parts. The mantissa, here 01101000, is read with the binary point after the first bit, which gives 0.1101000, or 0.8125. The exponent, here 0011, is 3. The value is the mantissa times 2 to the power of the exponent. The exponent moves the binary point three places to the right, turning 0.1101000 into 110.1000, which is 4 plus 2 plus 0.5, which is 6.5. A mantissa is normalised when its first two bits differ, 01 for a positive number or 10 for a negative one, so no accuracy is wasted on leading zeros. More mantissa bits give more precision, and more exponent bits give a bigger range.A number stored as a mantissa and an exponent101101000binary pointmantissa 0.1101000 = 0.8125x20011exponent 0011 = 3the power of 2The exponent moves the binary point20.11010003 places right110.1000= 6.5110.1000 = 4 + 2 + 0.5 = 6.5, and 0.8125 x 2^3 = 6.5 as well3Normalised: the first two mantissa bits differ (01 or 10), so no accuracy is wasted on leading zeros.More mantissa bits give more precision. More exponent bits give a bigger range.
  1. Mantissa times two to the power of the exponent. The binary point sits after the first mantissa bit.
  2. The exponent moves the point: 0.1101000 moved 3 places right is 110.1000, which is 6.5.
  3. Normalise so the first two bits differ. More mantissa bits give precision, more exponent bits give range.
Floating point trades precision against range, and most decimals cannot be stored exactly.

Boolean algebra

The operations

NotationMeaning
A.B or A AND BConjunction
A+B or A OR BDisjunction
A' or NOT ANegation
A XOR BExclusive or, true when exactly one input is true

The laws you must know

LawForm
IdentityA + 0 = A, A . 1 = A
NullA + 1 = 1, A . 0 = 0
IdempotentA + A = A, A . A = A
InverseA + A' = 1, A . A' = 0
CommutativeA + B = B + A
AssociativeA + (B + C) = (A + B) + C
DistributiveA . (B + C) = A.B + A.C
AbsorptionA + A.B = A, A . (A + B) = A
De Morgan's(A.B)' = A' + B' and (A+B)' = A' . B'

De Morgan's laws in words: break the bar and change the operator. The negation of an AND is the OR of the negations, and vice versa. This is examined almost every year.

Simplifying an expression

Simplify A.B + A.B'

A.B + A.B' = A.(B + B') distributive = A.1 inverse law = A identity law

Simplify (A + B).(A + B')

= A.A + A.B' + B.A + B.B' distributive = A + A.B' + A.B + 0 idempotent and inverse = A(1 + B' + B) factorise = A

Karnaugh maps

A visual method of simplification. Adjacent cells differ by exactly one variable, so grouping them eliminates that variable.

For two variables:

B'=0B=1
A'=010
A=111

Rules:

  1. Group only 1s, in rectangular groups of 1, 2, 4, 8 and so on
  2. Make groups as large as possible, since a larger group eliminates more variables
  3. Groups may overlap
  4. Groups wrap around the edges of the map
  5. Every 1 must be covered by at least one group

Here the left column groups vertically to give B', and the bottom row groups horizontally to give A, so the expression simplifies to A + B'.

Why simplify

Fewer terms means fewer logic gates, which means lower cost to manufacture, less power consumed, less heat produced, less physical space used and a shorter propagation delay through the circuit.

Simplifying a Boolean expression with a Karnaugh mapA four variable Karnaugh map with AB down the side and CD across the top, both labelled in Gray code order 00, 01, 11, 10 so that neighbouring cells differ in only one variable. The map holds a 1 in the whole of the CD equals 00 column, that is at AB 00, 01, 11 and 10, and also at AB equals 11 with CD equals 01 and CD equals 11. All other cells hold 0. The first group is the column of four cells: C and D are 0 in every one of them while A and B change, so that group simplifies to C NOT AND D NOT, written C'D'. The second group is the pair of cells in the AB equals 11 row at CD 01 and 11: A, B and D are 1 in both while C changes, so that group simplifies to A AND B AND D. The simplified expression is therefore Q equals C'D' plus A B D.Q = A'B'C'D' + A'BC'D' + ABC'D' + ABC'D + ABCD + AB'C'D'CDAB00011110000111101000100011101000group of 4C and D are both 0in all four cells,and A and B change,so the term is C'D'group of 2A, B and D are all 1in both cells, and Cchanges, so the termis A.B.DQ = C'D' + A.B.D
Groups must be rectangles of 1, 2, 4, 8 or 16 cells, may wrap around the edges, and may overlap. Bigger groups give shorter terms.

Logic gate simulator

Build a circuit from gates, wire it up, and see the truth table fill in as you go. This tool needs JavaScript, so turn it on to use it. Everything you need to answer the exam question is explained in the text above.

Tracing a signal through a logic circuitA circuit with two inputs, A and B, feeding an AND gate whose output feeds a NOT gate, which produces the output Q, drawn twice. Every wire carries a 1 or a 0, written on it, and a wire carrying a 1 is drawn lit. In the first case A is 1 and B is 0. The AND gate outputs 1 only when both its inputs are 1, so it outputs 0. The NOT gate inverts whatever it is given, so that 0 becomes a 1 and Q is 1, and the bulb is on. In the second case both A and B are 1, so the AND gate outputs 1, the NOT gate inverts it, and Q becomes 0 and the bulb is off. A truth table beside the circuit lists all four combinations, with Q equal to 1 in every row except the one where both inputs are 1. The whole circuit is Q equals NOT, bracket, A AND B, bracket, and a combination that common has its own name and symbol: it is a NAND gate. When reading a circuit in an exam, work left to right and write the value on every wire as you go, because the marks are for the intermediate columns as much as the answer.A = 1, B = 0ABANDNOT1001Q = 1A = 1, B = 1ABANDNOT1110Q = 0Truth tableABANDQ0001010110011110Q is 1 every timeexcept when A and Bare both 1Q = NOT (A AND B)that is a NAND gate12345
  1. Two inputs, one AND gate, one NOT gate, one output.
  2. A = 1 and B = 0. AND needs both, so it gives 0.
  3. NOT flips it, so Q becomes 1.
  4. A = 1 and B = 1. AND gives 1, NOT flips it, Q is 0.
  5. Q = NOT (A AND B). That is a NAND gate, written out.
Label every wire as you go. An intermediate column in a truth table is a mark, and it is also how you catch your own mistake.

Key terms you must be able to define

Two's complement
A signed integer representation where the most significant bit carries a negative place value.
Mantissa
The significant digits of a floating point number.
Exponent
The power of two by which the mantissa is multiplied in floating point representation.
Normalisation
Adjusting a floating point number so the mantissa begins 01 or 10, maximising precision.
Precision
How finely a value can be represented, determined by the number of mantissa bits.
Range
The span of values representable, determined by the number of exponent bits.
Bit mask
A pattern combined with a value using AND or OR to isolate or set particular bits.
De Morgan's laws
The rules that the negation of an AND is the OR of the negations, and vice versa.
Karnaugh map
A grid method for simplifying Boolean expressions by grouping adjacent ones.
Propagation delay
The time taken for a signal to pass through the gates of a circuit.

Flashcards

Say the definition out loud before you flip the card. Retrieving it from memory is what builds recall, reading it again is not.

DefineTwo's complement
AnswerA signed integer representation where the most significant bit carries a negative place value.
DefineMantissa
AnswerThe significant digits of a floating point number.
DefineExponent
AnswerThe power of two by which the mantissa is multiplied in floating point representation.
DefineNormalisation
AnswerAdjusting a floating point number so the mantissa begins 01 or 10, maximising precision.
DefinePrecision
AnswerHow finely a value can be represented, determined by the number of mantissa bits.
DefineRange
AnswerThe span of values representable, determined by the number of exponent bits.
DefineBit mask
AnswerA pattern combined with a value using AND or OR to isolate or set particular bits.
DefineDe Morgan's laws
AnswerThe rules that the negation of an AND is the OR of the negations, and vice versa.

Reach the top grade on this topic

  • Convert to and from two's complement in both directions, and state the range for n bits
  • Explain normalisation as maximising precision by removing wasted leading bits
  • State the precision against range trade off explicitly whenever floating point is discussed
  • Apply De Morgan's laws confidently in both directions
  • Show every step of a Boolean simplification, naming the law used
  • Justify simplification by cost, power, heat, space and propagation delay

Mistakes that cost marks here

Avoid these
  • Forgetting that the most significant bit in two's complement has a negative place value.
  • Forgetting the add one step when negating a two's complement number.
  • Saying more bits give both greater precision and greater range for a fixed total.
  • Applying De Morgan's law without changing the operator.
  • Making Karnaugh map groups that are not a power of two in size.
  • Simplifying without stating which law justified each step.
Fun fact

Floating point cannot represent 0.1 exactly, for the same reason denary cannot represent one third exactly. This is why financial systems store money as an integer number of pence rather than as a floating point value.

Knowledge check

0 of 10 answered
1What is 11101100 in denary as an 8 bit two's complement number?
2How do you negate a two's complement number?
3What is the range of an 8 bit two's complement number?
4In floating point, what does increasing the number of exponent bits do?
5What is the purpose of normalisation in floating point?
6Which is a correct statement of De Morgan's law?
7Simplify A.B + A.B'
8In a Karnaugh map, why should groups be as large as possible?
9What does x AND 00001111 achieve?
10Why is simplifying a Boolean expression worthwhile?
Score 0 / 10

Exam-style questions

Five written questions in the style of the real paper. Write a full answer, then let the marker check it against the mark scheme.

20 marks
1Convert the denary number -45 into 8 bit two's complement, showing your working.3 marks
Convert

Mark scheme0 / 3
  • LConverts 45 to binary as 00101101
  • LInverts all the bits to give 11010010
  • LAdds one to give 11010011
Model answer

First convert 45 into 8 bit binary: 32 + 8 + 4 + 1 = 45, giving 00101101. Then invert every bit, which produces 11010010. Finally add one, giving 11010011. Checking the result confirms it: -128 + 64 + 16 + 2 + 1 = -45.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
2Explain why a floating point number is normalised.3 marks
Explain

Mark scheme0 / 3
  • LNormalisation adjusts the mantissa so it begins 01 for positive or 10 for negative
  • LThis removes leading duplicate bits that carry no information
  • LThe greatest possible precision is obtained from the available mantissa bits
Model answer

A floating point value can be written in many equivalent ways by shifting the mantissa and adjusting the exponent to compensate, and most of those forms waste bits. Normalisation adjusts the number so that the mantissa begins with 01 for a positive value or 10 for a negative one, which guarantees that the leading bits actually carry information rather than simply repeating the sign. Because no mantissa bits are wasted on redundant leading zeros or ones, the maximum possible precision is obtained from the fixed number of bits available. Normalisation also gives every value a single unique representation, which makes comparison and arithmetic in hardware much simpler.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
3Explain the trade off between range and precision in floating point representation.4 marks
Explain

Mark scheme0 / 4
  • LThe mantissa determines precision
  • LThe exponent determines range
  • LThe total number of bits is fixed
  • LIncreasing one necessarily reduces the other
Model answer

In a floating point representation the mantissa holds the significant digits of the value and therefore determines how precisely a number can be represented, while the exponent determines how far the binary point can be shifted and therefore how large or small a magnitude can be expressed, which is the range. Because the total number of bits available for a value is fixed, every bit allocated to the exponent is a bit taken from the mantissa and vice versa. Increasing the exponent field allows very large and very small numbers to be represented but leaves fewer mantissa bits, so values are stored to fewer significant figures and rounding errors become larger. Increasing the mantissa gives greater accuracy for each stored value but restricts the magnitudes that can be represented at all. A designer must therefore choose the split according to whether the application needs to handle extreme magnitudes or to represent moderate values very accurately.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
4Simplify the Boolean expression A.B + A.B' + A'.B, showing each step and naming the law used.5 marks
Simplify

Mark scheme0 / 5
  • LFactorises A from the first two terms
  • LApplies the inverse law that B + B' equals 1
  • LSimplifies A.1 to A using the identity law
  • LReaches A + A'.B
  • LSimplifies to A + B using the absorption or distributive law
Model answer

Starting with A.B + A.B' + A'.B, factorise A out of the first two terms to give A.(B + B') + A'.B. By the inverse law B + B' equals 1, so this becomes A.1 + A'.B, and by the identity law A.1 is simply A, leaving A + A'.B. Applying the distributive law gives (A + A').(A + B), and since A + A' equals 1 by the inverse law this becomes 1.(A + B), which by the identity law simplifies to A + B. The final simplified expression is therefore A + B, reduced from three AND terms and two OR operations to a single OR gate.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
5State De Morgan's laws and explain why simplifying a Boolean expression is useful in circuit design.5 marks
State

Mark scheme0 / 5
  • LStates that the negation of an AND is the OR of the negations
  • LStates that the negation of an OR is the AND of the negations
  • LSimplification reduces the number of logic gates required
  • LThis lowers manufacturing cost and reduces power consumption and heat
  • LIt also reduces propagation delay so the circuit operates faster
Model answer

De Morgan's laws state that the complement of a conjunction equals the disjunction of the complements, written (A.B)' = A' + B', and that the complement of a disjunction equals the conjunction of the complements, written (A+B)' = A'.B'. In words, breaking the negation bar over an expression requires changing AND to OR or OR to AND. Simplification matters in circuit design because every term and every operator in a Boolean expression corresponds to physical logic gates on a chip. Reducing an expression from six gates to two directly reduces the number of transistors required, which lowers the manufacturing cost of every unit produced and reduces the physical area occupied on the die, allowing more circuitry in the same space. Fewer gates also draw less current, so the circuit consumes less power and generates less heat, which matters greatly in battery powered and densely packed devices. Finally, each gate a signal passes through introduces a small propagation delay, so a shallower simplified circuit produces its output sooner and can therefore be clocked at a higher frequency.

The marker looks for key phrases. If you said it another way and it is still right, give yourself the mark.
Machine mark 0 / 20