BU CS 101 - Representing Data in Binary
Pages 36

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 362-1Representing Data in Binary•Remember:–Coarse definition of a computer–Analog/Digital/Binary•In this lecture:–How computers are composed (somewhat)–formulating binary representations of data2-2Deciding Analog vs. Digital•General Purpose means its tasks may be changed–We intend to build a physical device that can be used for many different purposes.•Computers are composed of binary circuitry... –Binary is a subset of Digital; •it has only two possible conditions (on/off == true/false)•Binary circuits requires a source of electricity to function; hence these computers will also be electric.•why binary ?2-3The G-P,E,D Computer•Binary circuitry provides a means for physically representing and evaluating basic logical expressions (boolean logic)–the circuitry is adaptable such that we can represent different logic with the same physical circuitry!•read: programmable/general purpose–on top of very simple logic we will build more complicated things2-4The G-P,E,D Computer•Computer Hardware–The electronics and associated mechanical parts of the computer.–the hardware is capable of performing various tasks, as we instruct it•Computer Software–The instructions that control the hardware and cause the desired tasks to occur on the hardware–A disk is considered hardware. –A program on the disk is considered software.–A computer needs the hardware to take instructions, as well the means to take input, process it, and produce output.2-5Binary Circuitry•Binary circuitry: –cheap–reliable–able to be extended to very complicated logic •built on only two states»ON (1)»OFF (0)2-6Computers work in Binary•Computers are not only powered by electricity they “compute” with electricity–they shift voltage pulses around internally–circuits allow for electricity to flow or to be blocked depending on the type of circuitClosedcircuitOpencircuitON or 1OFF or 02-7Representation of Data•Our computer is comprised of binary circuitry–As such, it can only manipulate binary digits (bits)–Each bit is a single location that can be given a value of a 1 or a 0–We can store, retrieve, and manipulate a large number of bits•A computer's memory is a long series of bits–conceptually, we can think of a very long sequence of light bulbs (each bulb(bit) can be either on or off at a given point in time)2-8Representation of Data•As bits, the above can be represented as: 00010001–We need to represent more than just 1's and 0's:•Numbers •Characters•Visual Data•Audio Data•Instructions… somehow this must be done using 0’s and 1’s2-9Representation of Numbers•Representing a number is more than simply representing a symbol “1” or “2” or “430”–Numbers; have conceptual (and functional) meaning9 = 3+3+3 = 4+5 = 10-1 = 3*3 = 3^2 = 92-10Combinations•Imagine we have three light-bulbs in a row, and each bulb can be either on (1) or off (0).•How many unique sequences of light states can we have?–(Hint, start with all lights off)2-11Combinations•The number of unique sequences we can have of one light with two states per lights is two:•The number of unique sequences we can have of two lights with two states per light is four:•The number of unique sequences we can have of three lights with two states per lights is eight:00000101001110010111011101000110112-12Representation of Numbers•Our three-light system–has eight possible combinations of on and off.•With eight unique combinations, we could represent the numbers 0, 1, 2, 3, 4, 5, 6, 70 = 000 4 = 1001 = 001 5 = 1012 = 010 6 = 1103 = 011 7 = 1112-13Representation of Numbers•Decimal numeration system: (aka base 10)–Uses 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.–The place values of each position are increasing powers of ten.•A number such as 1428 literally means:–Eight Ones–Two Tens–Four Hundreds–One (A single) Thousand= (1 x 1000) + (4 x 100) + (2 x 10) + (8 x 1)1010101010012341101001000100002-14Representation of Numbers•Binary numeration system (aka base 2):–Will use 2 symbols: 0, and 1. (Recall, each is called a bit for binary digit)–The place values of each position are powers of two.–A binary number such as 10110two will be expanded as:•Zero Ones•One Two•One Four•Zero Eights•One Sixteen= (1 x 16) + (0 x 8) + (1 x 4) + (1 x 2) + (0 x 1) = 22 in decimal22222012341248160 1 1 012-15Binary-to-Decimal Conversion•Convert the following binary number (base two) in decimal (base ten) 1 0 0 0 0 0 1 12-16Binary Conversion1 0 0 0 0 0 1 1 •Step 1: Make a table with the same number of columns as places in the binary string and copy the string into the table110000012-17Binary Conversion•Step 2: Write out the powers of two corresponding to each position in the binary number: 1100000120212223242526272-18Binary Conversion•Step 3: Write out the powers of two corresponding to each position in the binary number in decimal:12481632641281100000120212223242526272-19Binary Conversion•Step 4: multiply the second and third rows and put the result in the fourth row:120000012812481632641281100000120212223242526272-20Binary Conversion•Step 5: (final step) – Add up all the numbers in the fourth row12000001281248163264128110000012021222324252627128+0+0+0+0+0+2+1 = 1312-21Decimal-to-Binary Conversion•Convert the decimal number 245 into binary.•Step 1: Figure out how many places we need by considering the value of each place and try to find the first value larger than our number–How can we know how many spaces we need to represent this number?•Hint: Think of the number of unique sequences we can obtain from a number of places . . . –What happens if we have too few spaces?2-22Decimal to Binary 2(number of bits) = the total number of unique combinations possible with that number of places in binary (bits); but we have to use one of the combinations for zero so. . . 2(number of bits) - 1 = largest decimal number we can store with that many bits1  21 – 1 = 1  with 1 place we can store numbers from 0 to 15  25 – 1 = 31  with 5 places we can store numbers from 0 to 317  27 – 1 = 127  with 7 places we can store numbers from 0 to


View Full Document

BU CS 101 - Representing Data in Binary

Download Representing Data in Binary
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Representing Data in Binary and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Representing Data in Binary 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?