Class Note for ENGIN 112 at UMass(13)
Class Note for ENGIN 112 at UMass(13)
Popular in Course
Popular in Department
This 17 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Massachusetts taught by a professor in Fall. Since its upload, it has received 26 views.
Reviews for Class Note for ENGIN 112 at UMass(13)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
College of Engineering University of Massachusetts Amherst ENGIN 112 Introduction to Electrical and Computer Engineering Fall 2008 Discussion A 2 Number Systems Decimal and Binary Number Systems Number representations make use of a base or radix A radixr system uses the r digits 0 1 r l Convention Let 01 02 be digits in the radixr set Then the radixr number 0K aKl 0100 3901 aIVI r T quotradix pointquot means aKx rKaK1 x rK391 01 x r1 00 x r0 a1 x r391 0M x r39M We most commonly use decimal radix10 number representations so decimal digits are 0 1 9 But computer arithmetic is based on binary radix2 number representations so binary digits or bits are 0 1 Converting a binary representation to a decimal representation is easy for example 1001110012 1x24 1x21 1x20 1x2391 1x2394 162112116 19562510 How do we convert decimal to binary Shorthand for procedure 25 2 12 remainder 1 9 00 1 1226 remainder0 9 010 6 2 3 remainder O 9 02 O 321remainder1 9 031a41 So 2510 110012 v Now Find the binary representation for 3810 ans 1001102 For numbers that have both integer and fractional parts Convert the two parts separately then put together Now Find the binary representation to 6 fractional bits of 6310 ans 1100100112 Other Number Systems Sometimes it is convenient to represent numbers using bases other than 10 or 2 In particular large binary numbers are often converted to octal radix 8 using digits 0 1 2 7 or hexadecimal radix 16 using digits 0 1 9 A B C D E F where A digit for quot10 B digit for quot11 F digit for quot15 Since three bits can be used to represent 0 1 7 we can convert binary to octal just by grouping bits in sets of three starting from the radix point Similarly four bits can be used to represent 0 1 15 so to convert binary to hexadecimal we group bits in sets of four starting from the radix point Now Convert 282510 to octal and hexadecimal ans 3428 10416 II Binary Arithmetic Addition and multiplication of binary numbers is done in the same way as with decimal numbers except that we can only use binary digits Examples 111 4 Carries 10101 10111 101100 Check 101012 10510 101112 11510 105 11 510 221o 101102 I 10111 x 10101 10111 0 10111 00 1011100 1110011 1011100 111100011 ChECC x 12075101111000112 u It s easiest to do the addition two terms at a time Now Find 1010112 100112 and 1010112 x 100112 ans 1010112 100112 11010012 1010112 x 100112 11001100012 Subtraction and Signed Binary Numbers Subtraction can be done using standard binary numbers but it is awkward to program Also if we want to allow for negative numbers we need some way to represent the sign or of a binary number Various ways of doing this are discussed in the textbook in Secs 15 and 16 We ll discuss the most commonlyused approach Signed2 s Complement representations Suppose we want to represent the positive integers 0 1 2 1 using n bits The nbit 2 scomplement representation for an integer N in this set is de ned to be the binary representation for the number 2 N The 2 s complement representation for 0 is de ned to be the binary representation for 0 Example Say we use 4 bits to represent the integers 0 1 15 Find the 4bit binary and 2 scomplement representations for 1410 n4 N14 2 N2 So binary representation is 1110 2 scomplement representation is 0010 Now suppose we need to represent the positive and negative integers in the set 2 391 2 391 1 1 O 1 2W 1 total of 2 digits This is most commonly done as follows we use the standard n bit binary representations for integers in the set 0 1 2 391 1 for negative integer N in the set 2 391 2 391 1 1 we use the nbit 2 scomplement representation for N Note that in this format All nonnegative integer representations have leftmost bit 0 while all negative integer representations have leftmost bit 1 so the leftmost bit is the sign bit This is called a signed 2 scompement representation Example Find the 4bit signed 2 scomplement representations of 610 and 410 610 0110 4bit 2 s complement representation of 410 4bit representation of 16 4 1210 11002 So 1100 3941o Now Suppose have signed 2 scomplement numbersA and B A B is computed in exactly the same way as with standard binary numbers except there is no carry of the sign bit A B is computed as A 2 s complement of B again with no carry of the sign bit Example Say we are using 5bit signed 2 s complement representations Show the binary operations for i 510 39 710 5bit 2 scomplement for 710 5bit rep for 32710 2510 110012 So have 00101 11001 11110 5bit signed 2 s complement representation for 321684210 210 t ii 151o 3961o 610 is represented by the 2 scomplement of 610 5bit rep for 32 610 11010 So have 01111 11010 01001 no carry of sign bit 910 t Now Using 4bit signed 2 s complement representations calculate 510 39610 ans 1111 110 Now suppose have numbers represented in 5bit signed 2 s complement format Say that we add 00111 to some number B and the result is 11110 What is B ans B 10111 910
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'