# The Building Blocks: Binary Numbers, Boolean Logic and Gates - PowerPoint PPT Presentation  Download Presentation The Building Blocks: Binary Numbers, Boolean Logic and Gates

The Building Blocks: Binary Numbers, Boolean Logic and Gates
Download Presentation ## The Building Blocks: Binary Numbers, Boolean Logic and Gates

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Basic Concepts of Electricity • Circuit: A path for electrons to flow through (Negatively charged electrons are attracted to positively charged electrons)

2. Basic Concepts of Electricity • Current:Flow of electrons through a conducting material measured in (amps) • Voltage: (Electrical pressure) The force which causes current to flow through an electrical conductor. (measured in volts)

3. Basic Concepts of Electricity • Resistance: (electrical friction): A property of materials that impedes current and causes the power loss in the form of heat dissipation. (measured in Ohm)

4. What is a CAPACITOR? Capacitor: (Reservoir)An electronic device that stores electricity. A simple capacitor consists of two conductors, separated by an insulating material called a dielectric. In the old days the Capacitor was called a condenser, but we don't use that name anymore. So what is a capacitor ? A capacitor is a special electrical component that you can use to charge it with electrons, or energy in the circuit. Once you charge the capacitor to it's maximum, it stays charged until you discharge it. It was called a capacitor, because this device possesses capacitance. Capacitance is the inherent property of electric circuit that opposes change in voltage. Property of circuit whereby energy may be stored in electrostatic fields and use to do something with later on or immediately.

5. Basic Concepts of Electricity • Transistor :A semiconductor,made of silicon and gallium arsenide, is a device that amplifies a signal or opens and closes a circuit. • In computers, it acts as a switch. • DiodeAn electronic device that controls the flow of electrons. A diode lets current flow in only one direction. • Transistors and other devices -- such as resistors, capacitors and diodes -- make up logic gates. Logic gates make up circuits, and circuits make up electronic systems, such as computers. See for more info. Transistor (router)

6. Logic Gates:Transistors and other devices -- such as resistors, capacitors and diodes -- make up logic gates. Logic gates make up circuits Circuits make up electronic systems, such as computers.

7. The Electronic Representation of Data How does data and instructions get “stored” inside the computer?

8. A look inside a memory chip: Each chip contains millions of capacitors lined up in nice, neat rows. Each capacitor has a transistor (switch) attached to it.

9. A capacitor can be charged or discharged When it’s charged, it represent the numeric value ‘1’. When it’s discharged, no current flow into a capacitor, it remains discharged. The discharged state represent the numeric value ‘0’. So a capacitor can be used to store a single digit - 0 or 1. That is why a single capacitor is called a bit - it stores a binary digit.

10. A SINGLE BIT- it’s a capacitor attached to a transistor. This is a single bit. It can be charged (representing the value ‘1’) or discharged (representing the value ‘0’) Power source Transistor current Capacitor Recall that the transistor acts as a switch. If it is “closed” it is acting as an insulator. It stops the flow of the current into the capacitor. If it is “open” it is acting as a conductor. It lets the current flow into the capacitor - allowing it to be charged or “on”.

11. Two stable electronic states are possible: On and off fully charged/fully discharged charged positively/charged negatively magnetized/nonmagnetized magnetized clockwise/magnetized ccw So, two digits can be represented electronically - 0 and 1.

12. All types of data is stored in these devices numeric values (base 10 numbers must be converted to base 2 numbers) (0000110 = 6, 0000111=7, etc.) character values (we used encoding schemes to convert letters of the alphabet to base-2 numeric values) (0100010=‘A’, 0100011=‘B’, etc.) images, sound, and full-motion video must also be converted into base-2 numeric values using encodingschemes. (0011=“white”, 1010=“green”, etc.)

13. FIRST, HOW DO WE HUMANS REPRESENT TEXT & NUMERIC DATA? • FOR NUMBERS, WE USE 10 DIFFERENT SYMBOLS (0,1,2,3,4,5,6,7,8,9). WE CALL THIS METHOD THE BASE 10 NUMBERING SYSTEM. • FOR LETTERS, WE USE 26 DIFFERENT SYMBOLS (A, B, C….). • FURTHER, WE USE “SIGN MAGNITUDE NOTATION” (A + OR - SIGN FOLLOWED BY A VALUE) TO DISTINQUISH BETWEEN POSITIVE AND NEGATIVE NUMBERS. • FOR FRACTIONS, WE USE DECIMAL POINTS TO SEPARATE THE WHOLE NUMBER PART FROM THE FRACTION.

14. How does a computer stores numeric values? How are numbers like 3,543 and -54 and 2.3454 and 1/5 represented in the computer’s memory? Base 10 numbers have to be converted to base 2 numbers in order to be stored internally by the computer.

15. Comparing decimal and binary system Let’s look at 2542. 2x103 +5x102 + 4x101 +2x100 Now, let’s look at 1011. 1x23 +0x22 + 1x21 +1x20

16. THE COMPUTER REPRESENTS ALL DATA ELECTRONICALLY • A CAPACITOR-LIKE DEVICE CAN BE ELECTRONICALLY CHARGED OR DISCHARGED. • IF IT IS CHARGED, IT IS SAID TO BE IN AN “ON” STATE. THIS ON-STATE REPRESENTS THE NUMERIC VALUE “1”. • IF IT IS DISCHARGED, IT IS SAID TO BE IN AN “OFF” STATE. THIS OFF-STATE REPRESENTS THE NUMERIC VALUE “0” • SO 1 DEVICE CAN BE USED TO REPRESENT ONE OF TWO POSSIBLE DIGITS. • SEE HANDOUT #1

17. 2 ELECTRONIC STATES CAN ONLY REPRESENT 2 NUMBERS - BUT THERE ARE 10 UNIQUE NUMBERS • HOW CAN IT WORK? • BASE 10 NUMBERS HAVE TO BE CONVERTED TO BASE 2 NUMBERS IN ORDER TO BE STORED INTERNALLY BY THE COMPUTER. • BASE 2 NUMBERS USE ONLY 1’S AND 0’S AS DIGITS. • BASE 2 NUMBERS CAN BE REPRESENTED IF WE USE SEVERAL OF THESE ELECTRONIC DEVICES Base 2 numbering system - a notation for representing values where only two unique symbols are used.

18. SO, TO REPRESENT A NUMBER OR LETTER IN A COMPUTER…. • LET’S SAY THAT WE CHOOSE TO USE 8 ELECTRONIC DEVICES TO STORE ONE SINGLE NUMBER • FIRST, THE NUMBER MUST BE CONVERTED TO AN 8-DIGIT, BASE-2 NUMBER • THEN, THE BASE 2 NUMBER CAN BE REPRESENTED BY A SERIES OF 8 ELECTRONIC DEVICES.

19. THE NUMBER x WOULD BE REPRESENTED AS y: x y____ 0 00000000 (ALL 8 DEVICES DISCHARGED) 1 00000001 (1ST 7 DEVICES DISCHARGED, 8TH IS CHARGED) 2 00000010 ETC. 3 00000011 4 00000100 5 00000101 6 00000110 7 00000111

20. A bit is a single storage unit. It can store a 0 or a 1. But computers are designed to use bits in sets of 8. (Typical values are 16, 32, 64) A set of 8 bits is called a byte. A byte is the smallest unit of storage in a computer. Therefore, all numeric values in a computer must contain at least 8 digits. Leading zeros will be used to hold the extra digits when necessary. Bytes vs. bits

21. THE NUMBER x IS REPRESENTED AS y: x y____ 0 00000000 (ALL 8 capacitors DISCHARGED) 1 00000001 (1ST 7 capacitors DISCHARGED, 8TH IS CHARGED) 2 00000010 ETC. 3 00000011 4 00000100 5 00000101 6 00000110 7 00000111

22. CONVERTING A NUMBER FROM BASE 2 TO BASE 10 TAKE 00000111: 1 * 20 (1) = 1 1 * 21 (2) = 2 1 * 22 (4) = 4 0 * 23 (8) = 0 0 * 24 (16) = 0 0 * 25 (32) = 0 0 * 26 (64) = 0 0 * 27 (128) = 0 7

23. CONVERTING A NUMBER FROM BASE 2 TO BASE 10 TAKE 11000111: 1 * 20 (1) = 1 1 * 21 (2) = 2 1 * 22 (4) = 4 0 * 23 (8) = 0 0 * 24 (16) = 0 0 * 25 (32) = 0 1 * 26 (64) = 64 1 * 27 (128) = 128 199

24. CONVERTING FROM BASE 10 TO BASE 2 • Take a number and subtract the highest 2? That you can without resulting in a negative number. • Keep subtractingthe highest 2? Until you get to 0. • Take 45. • Subtract 25 (32) • Get 13 • Subtract 23 (8) • Get 5 • Subtract 22 (4) • Get 1 • Subtract 20 (1) • Get 0 • Answer: 00101101 • (A “1” in the 5th, 3th, 2nd and 0th positions.) 0 0 1 0 1 1 0 1

25. Converting fractional numbers to base 2 Let’s look at the following example • In decimal system: .75= 7x10-1 + 5x10-2 • Representing .11=1x2-1+1x2-2 =1/2+ 1/4

26. Converting fractional numbers to base 2 Let’s try to convert .8 to binary number. • We can write .8=1/2+1/4 + 1/32+ 1/64+1/512 • Converting to binary: • .110011001

27. What’s the largest value that 8 bit devices can represent? • THE VALUE: 11111111 • 28 - 1 • WHICH IS?

28. Wow many different values can 8 bit devices represent? • 28 • WHICH IS?

29. SO HOW CAN THE COMPUTER STORE THE NUMBER 1 MILLION? • 1,000,000 is a 7-digit number in base 10 but it is a 20-digit number in base 2. It cannot be represented using only 8 bits! • We’ll need 20 bits instead of 8 to represent 1 million. • And we’ll need 24 bits to represent the number 10 million (a 24-digit number in base 2.)

30. DATA STRUCTURES If a program needs to use numbers (or other types of data) that are too large to fit into a single byte: • Programmers can can instruct the computer to (temporarily) create larger storage bins by grouping more than 8 bit devices together to create a single unit of storage. • A designated storage bin consisting of more than one byte is called a data structure.

31. Setting up data structures • As a programmer, you can write a declaration statement like this: • Integer x • Character y • Float c • Then, the computer will set aside the bytes you need to hold that type of data (integer, character, or float)

32. PROGRAMMING MODELS • Different computer languages allow you to designate different sizes and types of data structures. • In “c” language, you can create (declare) data structures that hold: • integers • long integers • characters • character strings • real numbers • large real numbers and so on

33. DECLARING STRUCTURES TO HOLD UNSIGNED INTEGERS: • In c, you can declare a structure to hold an unsigned integer like this: unsigned integer count • When this statement is executed in a program, the computer will set up a “storage bin” of size 4 bytes (on a Unix-based system) • Any value that is put in that storage bin will be interpreted as apositive integer.

34. WHAT’S THE LARGEST VALUE THAT THIS 4-BYTE STRUCTURE CAN HOLD? • 11111111111111111111111111111111 • 232 - 1 • Which is? • This is the largest value that can be represented in this data structure. • What’s the smallest value it can hold? 0

35. HOW MANY DIFFERENT NUMBERS CAN THIS 4-BYTE STRUCTURE HOLD? • 232 • WHICH IS?

36. PROGRAMMING MODELS • Different computer languages allow you to designate different sizes and types of data structures. • In c++, you can create data structures called objects that can hold “images”, “sound clips”, “video”, etc.

37. DECLARING STRUCTURES TO HOLD SIGNED INTEGERS: • In C++, you can declare a structure to hold a signed integer (includes a + or -) like this: signed integer counter • When this statement is executed in a program, the computer will set up a “storage bin” of size 4 bytes. • Any value that is put in that storage bin will be interpreted as a signed integer.

38. Representing Negative Numbers • Binary digits can be used to represent not only numbers but other forms of data as well, including + and - signs. • We can have a ‘1’ represent a negative sign (-) • and a ‘0’ represent a positive sign (+)

39. SUMMARIZING THE DIFFERENCE BETWEEN SIGNED NUMBERS AND UNSIGNED NUMBERS In C++, you can declare: • “signed integer” data structure • or an “unsigned integer” data structure The same binary code could represent different numbers depending on what type of structure it is stored in.

40. TAKE THE BINARY CODE: 1110001 As a signedinteger, 1110001 would be the value -49 As an unsignedinteger, 1110001 would be the value 113 As a character, 1110001 would be the “lower case ‘q’

41. WHAT IS THE LARGEST VALUE THAT CAN BE REPRESENTED IN A SIGNED INTEGER CELL? 011111111111111111111111111111111 First bit is used for the sign (+) or 2(32-1) -1

42. WHAT IS THE SMALLEST VALUE THAT CAN BE REPRESENTED IN A SIGNED INTEGER CELL? 11111111111111111111111111111111 or - (2(32-1) -1)

43. DECLARING STRUCTURES TO HOLD REAL NUMBERS: Real numbers, also called floating point: It can be any rational number 7.0 7 1/2

44. DECLARING STRUCTURES TO HOLD REAL NUMBERS: • A SIGNED FLOAT LIKE THIS: FLOAT SALES • WHEN THIS STATEMENT IS EXECUTED IN A PROGRAM, THE COMPUTER WILL SET UP A • STORAGE BIN OF SIZE 4 BYTES (32 BITS) • BUT 7.0 IN A FLOAT CELL IS REPRESENTED DIFFERENTLY THAN 7 IN AN INTEGER CELL.