Computer Science 1 - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Computer Science 1

Description:

One 3-hour written exam that includes both Discrete Maths and Special Topics ... In fact we can use any positive integer greater than 1 as the base of a number system. ... – PowerPoint PPT presentation

Number of Views:384
Avg rating:3.0/5.0
Slides: 31
Provided by: eri7158
Category:
Tags: computer | fact | science

less

Transcript and Presenter's Notes

Title: Computer Science 1


1
Computer Science 1
  • Erick Dube
  • 327 H1 Block
  • Westville
  • Tel (031) 260 1035
  • E-mail dubee2_at_ukzn.ac.za

2
Course Administration
  • This Discrete Maths part of the module basically
    comprises of three components
  • Number representation,
  • Circuits and computer components.
  • Simple Architecture Machine

3
Examination
  • The module will be examined at the end of the
    semester by
  • One 3-hour written exam that includes both
    Discrete Maths and Special Topics/Intro to
    Computer Sci.
  • Discrete Maths makes up 50 of the entire
    assessment.
  • The exam counts 50 of the final mark, with the
    class mark counting 50.
  • In order to pass Computer Science 1 you need 50
    for your final mark,
  • With a sub-minimum of 40 in the exam paper and
    the class mark

4
Discrete mathematics
  • Number Representations
  • Logic
  • Circuits and Computers

5
Number Representations
  • Number systems
  • Positional Systems
  • Other Bases
  • The decimal number system that we use in everyday
    calculations is a positional system. In such a
    system the position of the digit within the
    number determines the weight attached to that
    digit
  • When we write the number 1234 we really mean
  • 1234 1 1000 2 100 3 10 4 1
  • so that the right-most digit has weight 100 and
    the next digit has weight 101, the next 102, and
    so on. Writing it out this way is called expanded
    notation.

6
  • This system is called the decimal system because
    the weights
  • are powers of 10.
  • We say that the decimal system has base 10.
  • The decimal system is not the only way of
    representing numbers.
  • In fact we can use any positive integer greater
    than 1 as the base of a number system.
  • In base 5 the number 2314 means
  • 23145 253 3 52 1 51 4 50
  • Note that in Base 5 we use the digits 1,2,3,4

7
  • In general, to construct a positional system for
  • representing numbers we must select
  • An integer b gt 1 which is called the base of
    the system.
  • A set of b symbols to represent the digits
  • 0, 1, 2, 3, , b-1
  • Then a number such as
  • N an bn an-1 bn-1 . a1 b a0
  • where 0 ? ai lt b, is written as the sequence of
    digits
  • N anan-1an-2 ..a2 a1 a0
  • Here an is the most significant digit (provided
    its nonzero) and a0 is the least significant
    digit.

8
  • Determine the power of each digit for four-digit
    numbers in base 8.
  • 83 82 81 80
  • 512 64 8 1
  • Determine the power of each digit for five digit
    numbers in base 7.
  • 74 73 72 71 70
  • 2401 343 79 7 1

9
  • To distinguish the numbers written in different
    bases, it is usual to subscript the base
    immediately after the number. Thus 1234 in base 7
    is written as 12347. If no subscript is given
    then the number is assumed to be in decimal.

10
Common Bases
  • The four most important bases are
  • Decimal
  • base 10
  • Binary
  • base 2. This uses only the digits 0 and 1 which
    are called bits.
  • Hex (short for hexadecimal)
  • base 16.
  • This uses the digits 0, 1, 2, 3, 4,5, 6, 7, 8, 9,
    A, B,C,D,E, F. That is,A10, B11, C12, D13,
    E14 and F15.
  • Octal
  • base 8

11
Common Bases
12
Conversion between Bases
  • First Method of conversion
  • By weights
  • Convert the number 137548 to base 10
  • 83 82 81 80
  • 4096 512 64 8 1
  • 1 3 7 5 4
  • 4096 1536 448 40 4
  • Total 612410

13
  • By multiplication
  • Convert the number 137548 to base 10
  • 188
  • (83)888
  • (887)8760
  • (7605)86120
  • 61204612410

14
  • The method to convert from base 10 to another
    base ,
  • Find the value corresponding to the weight of
    each digit such that the total will add up to the
    base 10 number being converted.
  • The value for each digit must be the largest
    value that will not exceed the number being
    converted.

15
  • Convert 612410 to base 5.
  • The weights of each digit in base 5 are as
    follows
  • 15625 3125 625 125 25 5 1
  • 15625 digit is too large, 3125 fits into 6124
    only once with a remainder of 2999 thus the
    first digit is a 1.
  • Next digit , 625 goes into 2999 four times with a
    remainder of 499, 125 into 499 three times with
    remainder of 124, 25 into 124 four times, and so
    on. we get a final result of 1434445.

16
  • Second method of conversion
  • From Base 10 to another Base
  • Let B be the base to which we want to convert a
    number into. The number to convert , will be
    divided successively by the base, B, and each
    remainder is considered. We will do this until
    there is nothing left to divide. Each successive
    remainder represents the value of a digit in the
    new base , B, reading the new value from right to
    left

17
612410 to Base 5
1434445
18
Conversion between related Bases
  • Let B and R be two bases such that R Bt The
    conversion from base B into base R consists of
    breaking the number in base B into groups of t,
    starting from the least significant digit , and
    converting each group independently .
  • Eg 1624, converting from base 2 to base 16
    consists of breaking the binary number into
    groups of Four.

19
  • Let us convert 10010110111100102 to hexadecimal
  • 1624
  • grouping the binary number by fours, we have
  • 1001 0110 1111 0010
  • or
  • 9 6 F 216
  • The conversion in the reverse direction works
    identically

20
Arithmetic in different Bases
  • Decimal addition

21
Arithmetic in different Bases
  • Octal addition

22
Arithmetic in different Bases
  • Decimal Multiplication

23
Arithmetic in different Bases
  • Octal Multiplication

24
Arithmetic in different Bases
  • Binary Multiplication
  • 1101101
  • X 100110
  • 1101101
  • 1101101
  • 110110100000
  • 1000000101110

25
Fractions
26
Fractions
  • If we move the number point one place to the
    right in a number, the value of the number will
    be multiplied by the base.
  • For example
  • 129010 is 10 times as large as 129.010
  • The number point is known by the name of its
    base, for example binary point or hexadecimal
    point.
  • If we move the number point to the left one place
    , the value is divided by the base.

27
Fractions
28
Fractional Conversion Methods
  • The way to convert a fractional number from some
    base B to base 10 is to determine the appropriate
    weights for each digit, multiply each digit by
    its weight, and add the values.
  • Convert 0.1224 to base 10

29
  • the value is then
  • 0.250.1250.015625 0.39062510
  • To convert fractional numbers from 10 to another
    base, multiply the fraction by the base
    repeatedly, and record , then drop, the value
    that move to left of the radix point.
  • We repeat this until the desired number of digits
    of accuracy is attained or until the value being
    multiplied is zero.

30
  • Convert 0.82812510 to base 2. Multiplying by 2,
    we get
  • 0 .828125
  • 2
  • 1 .656250
  • 2
  • 1 .312500
  • 2
  • 0 .625000
  • 2
  • 1 .250000
  • 2
  • 0 .500000
  • 2
  • 1 .000000 The result is 0.1101012
Write a Comment
User Comments (0)
About PowerShow.com