Вы находитесь на странице: 1из 5

Discrete Mathematics 2002 Lecture 8, 8-August-2002

Computer Repn of Real Numbers


• Last lecture: The repn is based on the normalised
binary exponential form (nbe form) of a number
• nbe form is ± m × 2e, where m is the significand
(with 0.12 ≤ m < 1) & e is the exponent
• If 32 bits are available to store a real no, 1 bit is
for the sign, and typically 8 bits are used for the
exponent and 23 bits for the significand
• In fact, the exponent itself is not stored, but the
characteristic, where
characteristic = exponent + exponent bias
1

What Range of Real Nos can be


Stored in a Computer?
• We concluded last lecture by showing that if
real nos are stored in 32 bits, with 8 bits for the
char & an exp bias of 27 – 1 = 127, then the
range of positive nos that can be represented is
from 2–128 to 2128
• In decimal exponential form, this range is from
about 0.294 × 10–38 to 0.340 × 1039
• Likewise, the range of negative nos (with a sign
bit of 1) is from –0.294 × 10–38 to –0.340 × 1039
2

Overflow and Underflow


• If the result of a computation is outside the
allowed range, overflow or underflow occurs
• Overflow occurs if the magnitude of the no.
is too large – e.g. –0.568 × 1041 in our
example
• Underflow means the magnitude is too small
(the no. is too close to 0) – e.g. 0.767 × 10–39

1
Discrete Mathematics 2002 Lecture 8, 8-August-2002

Representation of Zero
• Note that 0 isn’t in any of the ranges we’ve
calculated for real nos that can be represented
in a computer
• This is because 0 can’t be written in
normalised binary exponential form
• The repn of 0 must be treated as a special case
• So, to store 0, use a string of bits that can’t be
interpreted as any other no. (e.g. all zeros)
4

Other Schemes to Represent Nos


• In practice, variations on the schemes we’ve
discussed are often used
• e.g. Because normalised binary exp form is used,
the 1st digit of the significand is always 1
• Thus the 1 can be omitted (it is implied), and an
extra bit of the significand can be included to
provide one extra bit of precision
• Arithmetic in a Computer: Using the repns we’ve
discussed, a computer employs various routines
to carry out arithmetic – but it’s tedious to work
through the details, and so we won’t do it!
5

4.1 Logic and Computing


• Instead of representing & manipulating
numbers, we now turn to the ideas of
mathematical logic
• Logic has applications in several areas of
computing – e.g. circuit design,
programming, design of algorithms, etc
• A frequent application of basic logic is to
the creation of specific criteria for searches
of databases or web pages
6

2
Discrete Mathematics 2002 Lecture 8, 8-August-2002

An Application of Logic
• Example: A Boolean search of web pages
using the search string
cat AND dog
yields all pages containing both ‘cat’ & ‘dog’
• A search using the string
cat OR (dog NOT horse)
lists all pages containing ‘cat’ or (‘dog’
without ‘horse’)

Example of a Boolean Search


cat cat
dog dog dog
horse horse horse
(1) (2) (3) (4)
• Example: Which of the above pages (1)-(4)
would be found by a Boolean search for
(a): cat OR (dog NOT horse)
(b): (cat OR dog) NOT horse
8

4.2 Propositions
• In arithmetic we work with numbers
• Similarly, the fundamental objects in logic
are propositions
• Definition: A proposition is a statement
that is either true or false. Whichever of
these is the case is called the truth value of
the proposition.

3
Discrete Mathematics 2002 Lecture 8, 8-August-2002

Examples of Propositions
1 ‘There are 200 cents in a dollar.’
2 ‘The 1956 Olympic Games were held in
Melbourne.’
3 ‘The assessment for Discrete Maths is 1 exam
and 2 tests.’
4 ‘To pass Discrete Maths you must gain a mark
of at least 50% on the exam.’
5 ‘Every even number greater than 2 is the sum
of two prime numbers.’
• (2) & (3) are true; (1) & (4) are false
• (5) is either true or false – noone knows which!
10

Goldbach’s Conjecture
• The proposition ‘Every even number greater
than 2 is the sum of two prime numbers’ is
known as Goldbach’s Conjecture
• It appears to be true – e.g. 20 = 7 + 13,
54 = 17 + 37, etc
• However, noone has been able to show that
every even no. is the sum of 2 prime nos.
• There was even a $1 million prize for a proof of
Goldbach’s Conjecture by 15 March 2002!
11

Examples of non-Propositions
1 ‘Stop talking.’
2 ‘What day of the week is it today?’
3 ‘This sentence is false.’
• (1) is a command & (2) is a question – so
neither are propositions
• (3) is a self-referential statement – i.e. it
makes a statement about itself
• (3) initially seems to be a proposition, but
problems occur when we try to determine
whether it is true or false
12

4
Discrete Mathematics 2002 Lecture 8, 8-August-2002

Paradoxes
• ‘This sentence is false’ is termed a paradox
• Paradoxes cause difficulties if we allow them as
propositions – so we won’t consider self-
referential statements at all in our work on logic
• Sentences such as ‘Winter is cold’ & ‘Football
is boring’ are sometimes not regarded as
propositions because it can be argued that their
truth values aren’t well defined
• We will allow such sentences as propositions
13

Predicates
• ‘y < 3’ is an example of a predicate
• A predicate is a statement which contains 1 or
more variables – it cannot be assigned a truth
value until the value(s) of the variable(s) are
specified
• e.g. if y = 2, the sentence is true, but if y = 4,
it is false
• We’ll look at predicate logic later in Chap. 4
14

Вам также может понравиться