PHY 201 (Blum)1 Binary Numbers. PHY 201 (Blum)2 Why Binary? Maximal distinction among values  minimal corruption from noise Imagine taking the same physical.

Slides:



Advertisements
Similar presentations
Number Bases Informatics INFO I101 February 9, 2004 John C. Paolillo, Instructor.
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
The Binary Numbering Systems
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Data Representation Computer Organization &
Data Representation COE 205
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language and Computer Architecture Using C++ and Java
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Binary, Decimal, & Hexadecimal Numbers
Mantıksal Tasarım – BBM231 M. Önder Efe
Topic 4 Computer Mathematics and Logic
Introduction to Computing Systems from bits & gates to C & beyond Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation.
Dr. Bernard Chen Ph.D. University of Central Arkansas
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
1 The Design of C: A Rational Reconstruction Jennifer Rexford.
CSIT 301 (Blum)1 Recap so far (Not gotten to last time) So there were issues about the number of operands. –Recall that we have a fetch-execute cycle –
Numbering systems.
Binary Numbers. Why Binary? Maximal distinction among values  minimal corruption from noise Imagine taking the same physical attribute of a circuit,
Computers Organization & Assembly Language
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
Binary Numbers.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
Basic Arithmetic (adding and subtracting)
Logic and Digital System Design - CS 303
PHY 201 (Blum) 1 Resistors Ohm’s Law and Combinations of Resistors See Chapters 1 & 2 in Electronics: The Easy Way (Miller & Miller)
IT253: Computer Organization
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
ICS312 Set 1 Representation of Numbers and Characters.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
1 DLD Lecture 18 Recap. 2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with.
Binary Numbers. Why Binary? Maximal distinction among values  minimal corruption from noise Imagine taking the same physical attribute of a circuit,
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Data Representation, Number Systems and Base Conversions
CSC 370 (Blum)1 Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter)
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
PHY 201 (Blum)1 Shift registers and Floating Point Numbers Chapter 11 in Tokheim.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
PHY 201 (Blum)1 Shift registers and Floating Point Numbers Chapter 11 in Tokheim.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Data Representation COE 308 Computer Architecture
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
3.1 Denary, Binary and Hexadecimal Number Systems
Data Representation Binary Numbers Binary Addition
Fundamentals & Ethics of Information Systems IS 201
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSC 370 (Blum)
Chapter 2 Bits, Data Types & Operations Integer Representation
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSIT 301 (Blum)
Binary Numbers.
Floating Point Numbers
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSIT 301 (Blum)
UNIT – 3 & 4. Data Representation and Internal
Data Representation COE 308 Computer Architecture
Presentation transcript:

PHY 201 (Blum)1 Binary Numbers

PHY 201 (Blum)2 Why Binary? Maximal distinction among values  minimal corruption from noise Imagine taking the same physical attribute of a circuit, e.g. a voltage lying between 0 and 5 volts, to represent a number The overall range can be divided into any number of regions

PHY 201 (Blum)3 Don’t sweat the small stuff For decimal numbers, fluctuations must be less than  0.25 volts For binary numbers, fluctuations must be less than  1.25 volts 5 volts 0 volts Decimal Binary

PHY 201 (Blum)4 Range actually split in three High Low Forbidden range

PHY 201 (Blum)5 It doesn’t matter …. Some of the standard voltages coming from a computer’s power are ideally supposed to be 3.30 volts, 5.00 volts and volts Typically they are 3.28 volts, 5.14 volts or volts or some such value So what, who cares

PHY 201 (Blum)6 How to represent big integers Use positional weighting, same as with decimal numbers 205 = 2    10 0 Decimal – powers of ten = 1         2 0 = = 205 Binary – powers of two

PHY 201 (Blum)7 Converting 205 to Binary 205/2 = 102 with a remainder of 1, place the 1 in the least significant digit position Repeat 102/2 = 51, remainder

PHY 201 (Blum)8 Iterate 51/2 = 25, remainder 1 25/2 = 12, remainder 1 12/2 = 6, remainder

PHY 201 (Blum)9 Iterate 6/2 = 3, remainder 0 3/2 = 1, remainder 1 1/2 = 0, remainder

PHY 201 (Blum)10 Recap        

PHY 201 (Blum)11 Finite representation Typically we just think computers do binary math. But an important distinction between binary math in the abstract and what computers do is that computers are finite. There are only so many flip-flops or logic gates in the computer. When we declare a variable, we set aside a certain number of flip-flops (bits of memory) to hold the value of the variable. And this limits the values the variable can have.

PHY 201 (Blum)12 Same number, different representation 5 using 8 bits using 16 bits using 32 bits

PHY 201 (Blum)13 Adding Binary Numbers Same as decimal; if the sum of digits in a given position exceeds the base (10 for decimal, 2 for binary) then there is a carry into the next higher position

PHY 201 (Blum)14 Adding Binary Numbers carries

PHY 201 (Blum)15 Uh oh, overflow * What if you use a byte (8 bits) to represent an integer A byte may not be enough to represent the sum of two such numbers. * The End of the World as We Know It

PHY 201 (Blum)16 Biggest unsigned integers 4 bit: 1111  15 = bit:  255 = 2 8 – 1 16 bit:  65535= 2 16 – 1 32 bit:  = 2 32 – 1 Etc.

PHY 201 (Blum)17 Bigger Numbers You can represent larger numbers by using more words You just have to keep track of the overflows to know how the lower numbers (less significant words) are affecting the larger numbers (more significant words)

PHY 201 (Blum)18 Negative numbers Negative x is the number that when added to x gives zero Ignoring overflow the two eight-bit numbers above sum to zero

PHY 201 (Blum)19 Two’s Complement Step 1: exchange 1’s and 0’s Step 2: add 1 (to the lowest bit only)

PHY 201 (Blum)20 Sign bit With the two’s complement approach, all positive numbers start with a 0 in the left-most, most-significant bit and all negative numbers start with 1. So the first bit is called the sign bit. But note you have to work harder than just strip away the first bit IS NOT the 8-bit version of –1

PHY 201 (Blum)21 Add 1’s to the left to get the same negative number using more bits -5 using 8 bits using 16 bits using 32 bits When the numbers represented are whole numbers (positive or negative), they are called integers.

PHY 201 (Blum)22 Biggest signed integers 4 bit: 0111  7 = bit:  127 = 2 7 – 1 16 bit:  32767= 2 15 – 1 32 bit:  = 2 31 – 1 Etc.

PHY 201 (Blum)23 Most negative signed integers 4 bit: 1000  -8 = bit:  = bit:  = bit:  = Etc.

PHY 201 (Blum)24 Riddle Is it 214? Or is it – 42? Or is it Ö? Or is it …? It’s a matter of interpretation How was it declared?

PHY 201 (Blum)25 3-bit unsigned and signed Think of an odometer reading and the car travels one more mile.

PHY 201 (Blum)26 Fractions Similar to what we’re used to with decimal numbers =3 · · · · · · =1 · · · · · · · · 2 -6 (  )

Places PHY 201 (Blum)27 Two’s place One’s place Half’s place Fourth’s place Eighth’s place Sixteenth’s place

PHY 201 (Blum)28 Decimal to binary Integer part 98 / 2 = 49 remainder 0 49 / 2 = 24 remainder 1 24 / 2 = 12 remainder 0 12 / 2 = 6 remainder 0 6 / 2 = 3 remainder 0 3 / 2 = 1 remainder 1 1 / 2 = 0 remainder

PHY 201 (Blum)29 Decimal to binary Fractional part 0.61  2 =  2 =  2 =  2 =  2 =  2 =

PHY 201 (Blum)30 Decimal to binary Put together the integral and fractional parts 

PHY 201 (Blum)31 Another Example (Whole number part) Integer part 123 / 2 = 61 remainder 1 61 / 2 = 30 remainder 1 30 / 2 = 15 remainder 0 15 / 2 = 7 remainder 1 7 / 2 = 3 remainder 1 3 / 2 = 1 remainder 1 1 / 2 = 0 remainder

PHY 201 (Blum)32 Checking: Go to All Programs/Accessories/Calculator

PHY 201 (Blum)33 Put the calculator in Programmer view

PHY 201 (Blum)34 Enter number, put into binary mode

PHY 201 (Blum)35 Another Example (fractional part) Fractional part  2 =  2 =  2 =  2 =  2 =  2 =  2 = … …

PHY 201 (Blum)36 Checking fractional part: Enter digits found in binary mode Note that the leading zero does not display.

PHY 201 (Blum)37 Convert to decimal mode, then

Edit/Copy result. Switch to Scientific View. Edit/Paste PHY 201 (Blum)38

PHY 201 (Blum)39 Divide by 2 raised to the number of digits (in this case 7, including leading zero) 12 34

PHY 201 (Blum)40 Finally hit the equal sign. In most cases it will not be exact

PHY 201 (Blum)41 Other way around Multiply fraction by 2 raised to the desired number of digits in the fractional part. For example.456  2 7 = Throw away the fractional part and represent the whole number 58  But note that we specified 7 digits and the result above uses only 6. Therefore we need to put in the leading 0. (Also the fraction is less than.5 so there’s a zero in the ½’s place.)

PHY 201 (Blum)42 Limits of the fixed point approach Suppose you use 4 bits for the whole number part and 4 bits for the fractional part (ignoring sign for now). The largest number would be = The smallest, non-zero number would be =.0625

PHY 201 (Blum)43 Floating point representation Floating point representation allows one to represent a wider range of numbers using the same number of bits. It is like scientific notation. We’ll do this later in the semester.

PHY 201 (Blum)44 Hexadecimal Numbers Even moderately sized decimal numbers end up as long strings in binary Hexadecimal numbers (base 16) are often used because the strings are shorter and the conversion to binary is easier There are 16 digits: 0-9 and A-F

PHY 201 (Blum)45 Decimal  Binary  Hex 0  0000  0 1  0001  1 2  0010  2 3  0011  3 4  0100  4 5  0101  5 6  0110  6 7  0111  7 8  1000  8 9  1001  9 10  1010  A 11  1011  B 12  1100  C 13  1101  D 14  1110  E 15  1111  F

PHY 201 (Blum)46 Binary to Hex Break a binary string into groups of four bits (nibbles) Convert each nibble separately EC9

PHY 201 (Blum)47 Addresses With user friendly computers, one rarely encounters binary, but we sometimes see hex, especially with addresses To enable the computer to distinguish various parts, each is assigned an address, a number Distinguish among computers on a network Distinguish keyboard and mouse Distinguish among files Distinguish among statements in a program Distinguish among characters in a string

PHY 201 (Blum)48 How many? One bit can have two states and thus distinguish between two things Two bits can be in four states and … Three bits can be in eight states, … N bits can be in 2 N states

PHY 201 (Blum)49 IP(v4) Addresses An IP(v4) address is used to identify a network and a host on the Internet It is 32 bits long How many distinct IP addresses are there?

PHY 201 (Blum)50 Characters We need to represent characters using numbers ASCII (American Standard Code for Information Interchange) is a common way A string of eight bits (a byte) is used to correspond to a character Thus 2 8 =256 possible characters can be represented Actually ASCII only uses 7 bits, which is 128 characters; the other 128 characters are not “standard”

PHY 201 (Blum)51 Unicode Unicode uses 16 bits, how many characters can be represented? Enough for English, Chinese, Arabic and then some.

PHY 201 (Blum)52 ASCII 0  (48) 1  (49) … A  (65) B  (66) … a  (97) b  (98) …

PHY 201 (Blum)53 Booleans A Boolean variable is something that is true or false Booleans have two states and could be represented by a single bit (1 for true and 0 for false) Booleans appearing in a program will take up a whole word in memory

PHY 201 (Blum)54 Boolean Operators A.k.a. logical operators Have Boolean input and Boolean output Standard: AND OR NOT XOR (either or but not both) NOR = NOT(OR) NAND = NOT(AND)

PHY 201 (Blum)55 Truth Tables AND INPUTOUTPUT ABA AND B

PHY 201 (Blum)56 Truth Tables (Cont.) OR INPUTOUTPUT ABA OR B

PHY 201 (Blum)57 Truth Tables (Cont.) XOR (Excluded OR) INPUTOUTPUT ABA XOR B

PHY 201 (Blum)58 Numbers from Logic All of the numerical operations we have talked about are really just combinations of logical operations E.g. the adding operation is just a particular combination of logic operations Possibilities for adding two bits 0+0=0 (with no carry) 0+1=1 (with no carry) 1+0=1 (with no carry) 1+1=0 (with a carry)

PHY 201 (Blum)59 Addition Truth Table INPUTOUTPUT AB Sum A XOR B Carry A AND B

PHY 201 (Blum)60 All is NAND Actually you can use one logic gate (the NAND) and a few tricks (like De Morgan’s theorem) to build all of the “combinatorial” circuitry (the circuitry that doesn’t involve memory) NORs work too But we tend to think in ANDs, ORs and NOTs

PHY 201 (Blum)61 Bit manipulation You can use an AND to select out part of a word (where s is a 1 or 0, etc) stuvwxyz stuv0000 AND gives

PHY 201 (Blum)62 IP Addresses Revisted LaSalle’s IP address is what’s called a Class B IP address Of the 32 bits the first two bits are 10 (this identifies us as Class B) The remaining 14 bits of the first two bytes identify us as LaSalle The remaining 2 bytes are for our internals use (to assign computers within LaSalle)

PHY 201 (Blum)63 In or Out To see if an address is local to LaSalle, you would restrict your attention to the first two bytes. HOW? AND it with FFFF0000

PHY 201 (Blum)64 Subnets A network (like LaSalle’s) can be divided further into sub-networks Then subnet masks are used to determine whether or not another computer is on the same subnet