Академический Документы
Профессиональный Документы
Культура Документы
1
Discrete Mathematics 2002 Lecture 6, 2-August-2002
2
Discrete Mathematics 2002 Lecture 6, 2-August-2002
Subtraction in a Computer
• Subtraction of integers using computer
repns is straightforward because:
– the subtraction of b from a is the same as
adding –b to a (i.e. a – b = a + (–b) ), and
we already know how to add nos
– the repn of –b is the 2’s complement of
the repn of b (except for the repn of –8)
• Thus: Subtraction is performed by adding
the 2’s complement of the number
8
Example of Subtraction
• Example: Illustrate how a 4-bit computer
evaluates 7 – 4
• Why is the the 2’s complement method used
for subtraction in a computer?
Answer: The method does not require a
computer to have ‘subtracters’ in its
circuitry – all it needs are ‘adders’ (and a
means for calculating 2’s complements)
9
3
Discrete Mathematics 2002 Lecture 6, 2-August-2002
10
Exponential Notation
• If you had 12g of carbon-12, you’d have
6.0221367 × 1023 atoms (Avogadro’s no.)
• This is not written as 60221367 followed by
16 zeros, for 2 reasons – it is inconvenient
& it is wrong (or, at least, quite misleading)
• It is wrong because from the way the no. is
written, all we can say is that it is between
6.02213665 × 1023 and 6.02213675 × 1023
• So writing 60221367 followed by 16 zeros
could be in error by up to 5 million billion!
11
4
Discrete Mathematics 2002 Lecture 6, 2-August-2002