Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMP 100 Introduction to Computing Lecture Binary Numbers & Logic Operations.

Similar presentations


Presentation on theme: "CMP 100 Introduction to Computing Lecture Binary Numbers & Logic Operations."— Presentation transcript:

1 CMP 100 Introduction to Computing Lecture Binary Numbers & Logic Operations

2 Learning Goals for Today 1.To become familiar with number system used by the microprocessors - binary numbers 2.To become able to perform decimal-to-binary conversions 3.To understand the NOT, AND, OR and XOR logic operations – the fundamental operations that are available in all microprocessors

3 BINARY (BASE 2) numbers

4 DECIMAL (BASE 10) numbers

5 Decimal (base 10) number system consists of 10 symbols or digits 0 1 2 3 4 5 6 7 8 9

6 Binary (base 2) number system consists of just two 0 1

7 Other popular number systems Octal –base = 8 –8 symbols (0,1,2,3,4,5,6,7) Hexadecimal –base = 16 –16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

8 Decimal (base 10) numbers are expressed in the positional notation 4202 = 2x10 0 + 0x10 1 + 2x10 2 + 4x10 3 The right-most is the least significant digit The left-most is the most significant digit

9 Decimal (base 10) numbers are expressed in the positional notation 4202 = 2x10 0 + 0x10 1 + 2x10 2 + 4x10 3 1’s multiplier 1

10 Decimal (base 10) numbers are expressed in the positional notation 4202 = 2x10 0 + 0x10 1 + 2x10 2 + 4x10 3 10’s multiplier 10

11 Decimal (base 10) numbers are expressed in the positional notation 4202 = 2x10 0 + 0x10 1 + 2x10 2 + 4x10 3 100’s multiplier 100

12 Decimal (base 10) numbers are expressed in the positional notation 4202 = 2x10 0 + 0x10 1 + 2x10 2 + 4x10 3 1000’s multiplier 1000

13 Binary (base 2) numbers are also expressed in the positional notation 10011 = 1x2 0 + 1x2 1 + 0x2 2 + 0x2 3 + 1x2 4 The right-most is the least significant digit The left-most is the most significant digit

14 Binary (base 2) numbers are also expressed in the positional notation 10011 = 1x2 0 + 1x2 1 + 0x2 2 + 0x2 3 + 1x2 4 1’s multiplier 1

15 Binary (base 2) numbers are also expressed in the positional notation 10011 = 1x2 0 + 1x2 1 + 0x2 2 + 0x2 3 + 1x2 4 2’s multiplier 2

16 Binary (base 2) numbers are also expressed in the positional notation 10011 = 1x2 0 + 1x2 1 + 0x2 2 + 0x2 3 + 1x2 4 4’s multiplier 4

17 Binary (base 2) numbers are also expressed in the positional notation 10011 = 1x2 0 + 1x2 1 + 0x2 2 + 0x2 3 + 1x2 4 8’s multiplier 8

18 Binary (base 2) numbers are also expressed in the positional notation 10011 = 1x2 0 + 1x2 1 + 0x2 2 + 0x2 3 + 1x2 4 16’s multiplier 16

19 Counting in Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36... 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111 100000 100001 100010 100011 100100... Counting in Binary

20 Why binary ? Because this system is natural for digital computers The fundamental building block of a digital computer – the switch – possesses two natural states, ON & OFF. It is natural to represent those states in a number system that has only two symbols, 1 and 0, i.e. the binary number system In some ways, the decimal number system is natural to us humans. Why?

21 bit binary digit

22 Byte = 8 bits

23 Decimal Binary conversion

24 Convert 75 to Binary 752 3712 1812 902 412 202 102 01 1001011 remainder

25 Check 1001011=1x2 0 + 1x2 1 + 0x2 2 + 1x2 3 + 0x2 4 + 0x2 5 + 1x2 6 =1 + 2 + 0 + 8 + 0 + 0 + 64 =75

26 Convert 100 to Binary 1002 5002 2502 1212 602 302 112 01 1100100 remainder

27 That finishes our first topic - introduction to binary numbers and their conversion to and from decimal numbers Our next topic is …

28 Boolean Logic Operations

29 Let x, y, z be Boolean variables. Boolean variables can only have binary values i.e., they can have values which are either 0 or 1 For example, if we represent the state of a light switch with a Boolean variable x, we will assign a value of 0 to x when the switch is OFF, and 1 when it is ON

30 A few other names for the states of these Boolean variables 01 OffOn LowHigh FalseTrue

31 We define the following logic operations or functions among the Boolean variables NameExampleSymbolically NOT y = NOT( x ) x´x´ AND z = x AND y x · y OR z = x OR y x + y XOR z = x XOR y x  y

32 We’ll define these operations with the help of truth tables what is the truth table of a logic function A truth table defines the output of a logic function for all possible inputs ?

33 Truth Table for the NOT Operation (y true whenever x is false) xy = x´ 0 1

34 Truth Table for the NOT Operation xy = x´ 01 10

35 Truth Table for the AND Operation (z true when both x & y true) xyz = x · y 00 01 10 11

36 Truth Table for the AND Operation xyz = x · y 000 010 100 111

37 Truth Table for the OR Operation (z true when x or y or both true) xyz = x + y 00 01 10 11

38 Truth Table for the OR Operation xyz = x + y 000 011 101 111

39 Truth Table for the XOR Operation (z true when x or y true, but not both) xy z = x  y 00 01 10 11

40 Truth Table for the XOR Operation xy z = x  y 000 011 101 110

41 Those 4 were the fundamental logic operations. Here are examples of a few more complex situations z = (x + y)´ z = y · (x + y) z = (y · x)  w STRATEGY: Divide & Conquer

42 xy x + y z = (x + y)´ 0001 0110 1010 1110

43 xy x + yz = y · (x + y) 0000 0111 1010 1111

44 xy wy · x z = (y · x)  w 00000 00101 01000 01101 10000 10101 11011 11110

45 Number of rows in a truth table? 2 n n = number of input variables

46 Assignment # 3 A.Convert the following into binary numbers: i.The last three digits of your roll number ii.256 B.x, y & z are Boolean variables. Determine the truth tables for the following combinations: i. ( x · y) + y ii. (x  y)´ + w Consult the CS101 syllabus for the submission instructions & deadline

47 What have we learnt today? 1.About the binary number system, and how it differs from the decimal system 2.Positional notation for representing binary and decimal numbers 3.A process (or algorithm) which can be used to convert decimal numbers to binary numbers 4.Basic logic operations for Boolean variables, i.e. NOT, OR, AND, XOR, NOR, NAND, XNOR 5.Construction of truth tables (How many rows?)

48 What have we learnt today? 1.About the binary number system, and how it differs from the decimal system 2.Positional notation for representing binary and decimal numbers 3.A process (or algorithm) which can be used to convert decimal numbers to binary numbers 4.Basic logic operations for Boolean variables, i.e. NOT, OR, AND, XOR, NOR, NAND, XNOR 5.Construction of truth tables (How many rows?)


Download ppt "CMP 100 Introduction to Computing Lecture Binary Numbers & Logic Operations."

Similar presentations


Ads by Google