Understanding Computers Today and Tomorrow 13 th Edition
- Slides: 61
Understanding Computers: Today and Tomorrow, 13 th Edition Numbering systems Understanding Computers: Today and Tomorrow, 13 th Edition
Learning Objectives Understand identify a few of the coding systems. Understanding Computers: Today and Tomorrow, 13 th Edition 2
Data and Program Representation • Digital computers: Can only understand two states, off and on (0 and 1) • Digital data representation: The process of representing data in digital form so it can be understood by a computer Understanding Computers: Today and Tomorrow, 13 th Edition 3
Digital Data Representation • Bit: The smallest unit of data that a binary computer can recognize (a single 1 or 0) • Byte = 8 bits , Nibble =4 bits • Byte terminology used to express the size of documents and other files, programs, etc. • Prefixes are often used to express larger quantities of bytes: kilobyte (KB), megabyte (MB), gigabyte (GB), terabyte (TB), etc. Understanding Computers: Today and Tomorrow, 13 th Edition 4
Quiz I have a 2 Gb Flash memory. How many 512 Kb files can I store on the Flash memory? Note Mb is in common use for Megabit e. g. 200 Megabit = 200 Mb Answer Convert 2 Gb to Kb MB is in common use 2 x 1024=2048 Mb for Megabyte , e. g. 200 Mega. Byte=200 MB Convert from Mb to Kb 2048 x 1024= 2097152 kb Number of files= 2097152/ 512 = 4096 file Understanding Computers: Today and Tomorrow, 13 th Edition 5
Numbering Systems • A numbering system is a way of representing numbers. • A number is represented as a string of digits, e. g. , a number N with n digits represented by sequence dn-1, …, d 1, d 0 Understanding Computers: Today and Tomorrow, 13 th Edition
Numbering Systems • Positional notation – A system of expressing numbers in which the digits are arranged in succession, the position of each digit has a place value, and the number is equal to the sum of the products of each digit by its place value. • Determination of a number require the following : – The digits or symbols; – The positional of the digit in the number; – The base of the number system. Understanding Computers: Today and Tomorrow, 13 th Edition
Numbering Systems • Base ( radix ) – The base of a number system is simply the number of different digits, including zero that exist in the number system. – A number system of radix r, typically has a set of r allowed digits belongs to {0, 1, …, r-1} • We write a number N in the number system of radix r by expressing it in the form (N)r or Nr – (12)10 1 and 2 are digits in base 10, 325 2 and 3 are digits in base 5 i. e. , belongs to {0, 1, . . , 4} Understanding Computers: Today and Tomorrow, 13 th Edition
Numbering Systems • a radix point is the symbol used in numerical representations to separate the integer part of a number (to the left of the radix point) from its fractional part (to the right of the radix point). – Ex. 13. 62510, • 13 is the integer to the left of the radix point, and • 625 (i. e. 625/1000) is the fractional part to the right. Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Decimal Numbers • The numbering system we commonly use called the decimal numbering system because it uses 10 digits - symbols - (0, 1, 2, …, 9) to represent all possible numbers. • Why do we use 10 digits, anyway? • Numbers greater than nine such as 7216 represented using combination of these 10 digits. Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Decimal Numbers • • • Decimal numbers are made of decimal digits: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) But how many items does a decimal number represent? – 8653 = 8 x 103 + 6 x 102 + 5 x 101 + 3 x 100 What about fractions? – 97654. 35 = 9 x 104 + 7 x 103 + 6 x 102 + 5 x 101 + 4 x 100 + 3 x 10 -1 + 5 x 10 -2 – In formal notation -> (97654. 35)10 Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Octal Numbers • • Octal numbers are made of octal digits: (0, 1, 2, 3, 4, 5, 6, 7) How many items does an octal number represent? – (4536)8 = 4 x 83 + 5 x 82 + 3 x 81 + 6 x 80 = (1362)10 What about fractions? – (465. 27)8 = 4 x 82 + 6 x 81 + 5 x 80 + 2 x 8 -1 + 7 x 8 -2 Octal numbers don’t use digits 8 or 9 Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Binary Numbers • • • Binary numbers are made of binary digits (bits): – 0 and 1 How many items does an binary number represent? – (1011)2 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20 = (11)10 What about fractions? – (110. 10)2 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2 -1 + 0 x 2 -2 Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Computers: Today and Tomorrow, 13 th Edition
Understanding Hexadecimal Numbers • • • Hexadecimal numbers are made of 16 digits: – (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) How many items does an hex number represent? – (3 A 9 F)16 = 3 x 163 + 10 x 162 + 9 x 161 + 15 x 160 = 1499910 What about fractions? – (2 D 3. 5)16 = 2 x 162 + 13 x 161 + 3 x 160 + 5 x 16 -1 = 723. 312510 Note that each hexadecimal digit can be represented with four bits. – (1110) 2 = (E)16 Groups of four bits are called a nibble. – (1110) 2 Understanding Computers: Today and Tomorrow, 13 th Edition
Representing Numerical Data • Least Significant Digit (LSD) is the right most digit has the lowest value • Most Significant Digit (MSD) is the left most digit has the highest value • The most significant symbol can not be zero Example: Show the value of the number (9375)10 is estimated position Weight Digit Value 3 2 1 0 103 102 101 100 9 3 7 5 9 x 1000 3 x 100 7 x 10 5 x 1 5 is the least significant digit (LSD) 9 is the most significant digit (MSD) Understanding Computers: Today and Tomorrow, 13 th Edition 9375
Representing Numerical Data Commonly used numbering systems A. Decimal number system base =10, Ten allowed digits{0, 1, …, 9} B. Binary number system base= 2, Two allowed digits {0, 1} A. A Binary digit is referred to as Bit B. Most significant Bit (MSB) is the leftmost bit has the highest value C. Least significant Bit (LSB) is the rightmost bit has the lowest value C. Octal number system base =8, Eight allowed digits {0, 1, 2, …, 7} D. Hexadecimal number system base = 16, Sixteen allowed digits {0, 1, …, 9, A, B, C, D, E, F} Where, A= ten , B= eleven, C=Twelve, D= thirteen, E=fourteen, F= fifteen Q. Why is the digit following 9 assigned the character A not 10 ? Understanding Computers: Today and Tomorrow, 13 th Edition
Check point Q. What is the largest value can be represented in three integral digits? ------------------------------For the decimal system, it is (- - - )10 For the octal system, it is (- - - )8 For the hex system, it is (- - - )16 For the binary system, it is (- - - )2 ------------------------------Hint (The largest value results when all 3 positions are filled with the largest digit in the number system) Answer • • For the decimal system, it is ( 999 )10 For the octal system, it is ( 777 )8 For the hex system, it is ( fff )16 For the binary system, it is ( 111 )2 Understanding Computers: Today and Tomorrow, 13 th Edition
Conversion Between Number Bases Octal(base 8) Decimal(base 10) Binary(base 2) Hexadecimal (base 16) ° Learn to convert between bases. Understanding Computers: Today and Tomorrow, 13 th Edition
Representing Numerical Data Converting between numbering systems 1. Converting from decimal to any base 2. Converting from any base to decimal 3. Converting from any base to any base 4. A special conversion case number bases that are related (Shortcut method to/from binary ) Understanding Computers: Today and Tomorrow, 13 th Edition
Convert an Integer from Decimal to Another Base For each digit position: 1. Divide decimal number by the base (e. g. 2) 2. The remainder is the lowest-order digit 3. Repeat first two steps until no divisor remains. Example for (13)10: Integer Remainder Quotient Coefficient 13/2 = 6 + ½ a 0 = 1 6/2 = 3 + 0 a 1 = 0 3/2 = 1 + ½ a 2 = 1 1/2 = 0 + ½ a 3 = 1 Answer (13)10 = (a 3 a 2 a 1 a 0)2 = (1101)2 Understanding Computers: Today and Tomorrow, 13 th Edition LSB MSB
Repeated Division-by-r § To convert a whole number to the new base r, use successive division by r until the quotient is 0. The remainders form the answer, with the first remainder as LSB or LSD and the last as MSB or MSD. Example: (43)10 = (? )2 (43)10 = (101011)2 Understanding Computers: Today and Tomorrow, 13 th Edition
Convert an Fraction from Decimal to Another Base For each digit position: 1. Multiply decimal number by the base (e. g. 2) 2. The integer is the highest-order digit 3. Repeat first two steps until fraction becomes zero. Example for (0. 625)10: Integer Fraction Coefficient 0. 625 x 2 = 1 + 0. 25 a -1 = 1 0. 250 x 2 = 0 + 0. 50 a -2 = 0 0. 500 x 2 = 1 + 0 a -3 = 1 Answer (0. 625) 10 = (0. a-1 a-2 a-3 )2 = (0. 101)2 Understanding Computers: Today and Tomorrow, 13 th Edition MSB LSB
Repeated Multiplication-by-r § To convert decimal fractions to binary, repeated multiplication by r is used, until the fractional product is 0 (or until the desired number of digits of accuracy obtained). The carried digits, or carries, produce the answer, with the first carry as the MSB or MSD, and the last as the LSB or MSD. Example: (0. 3125)10 = (. 0101)2 Understanding Computers: Today and Tomorrow, 13 th Edition
Note For a number that has both integral and fractional parts, • conversion is done separately for both parts, and • then the result is put together with a system point in between both parts. Understanding Computers: Today and Tomorrow, 13 th Edition
2 -Any base r-to-Decimal Conversion • • Base-r to decimal: multiply digits with their corresponding weights. Examples § (1101. 101)2 = 1 23 + 1 22 + 1 20 + 1 2 -1 + 1 2 -3 = 8 + 4 + 1 + 0. 5 + 0. 125 = (13. 625)10 § (572. 6)8 = 5 82 + 7 81 + 2 80 + 6 8 -1 = 320 + 56 + 2 + 0. 75 = (378. 75) 10 § Convert 3 b 216 to decimal. N = 3*162 + 11*161 + 2*160 = 94610 § Convert 3708 to decimal. N = 3*82 + 7*81 + 0*80 = 192 + 56 + 0 = 24810 Understanding Computers: Today and Tomorrow, 13 th Edition
3 -Conversion between Bases § In general, conversion between bases can be done via decimal: Base-2 Base-3 Base-4 … Base-R Decimal Base-2 Base-3 Base-4 …. Base-R § First convert given number to decimal then convert decimal number to the new base. Understanding Computers: Today and Tomorrow, 13 th Edition
Converting Between Base 16 and Base 2 3 A 9 F 16 = 0011 1010 1001 11112 3 ° A 9 F Conversion is easy! Ø Determine 4 -bit value for each hex digit ° Note that there are 24 = 16 different values of four bits ° Easier to read and write in hexadecimal. ° Representations are equivalent! Understanding Computers: Today and Tomorrow, 13 th Edition
Converting Between Base 16 and Base 8 3 A 9 F 16 = 0011 1010 1001 11112 3 A 9 F 352378 = 011 101 010 011 1112 3 5 2 3 7 1. Convert from Base 16 to Base 2 2. Regroup bits into groups of three starting from right 3. Ignore leading zeros 4. Each group of three bits forms an octal digit. Understanding Computers: Today and Tomorrow, 13 th Edition
A special conversion case number bases that are related (Shortcut method to/from binary ) • Grouping of several digits in the smaller number base corresponds exactly to single digit in the larger number base • Examples § Binary Octal: Partition in groups of 3 (10 111 001. 101 110)2 = (2731. 56)8 § Octal Binary: reverse (2731. 56)8 = (10 111 001. 101 110)2 § Binary Hexadecimal: Partition in groups of 4 (101 1001. 1011 1000)2 = (5 D 9. B 8)16 § Hexadecimal Binary: reverse (5 D 9. B 8)16 = (101 1001. 1011 1000)2 Understanding Computers: Today and Tomorrow, 13 th Edition
Arithmetic operation on numbering systems • • Addition Subtraction Multiplication division Understanding Computers: Today and Tomorrow, 13 th Edition
Decimal Addition Example Add 3758 to 4657: 111 3 7 5 8 + 4657 8 415 1) Add 8 + 7 = 15 Write down 5, carry 1 2) Add 5 + 1 = 11 Write down 1, carry 1 3) Add 7 + 6 + 1 = 14 Write down 4, carry 1 4) Add 3 + 4 + 1 = 8 Write down 8 Understanding Computers: Today and Tomorrow, 13 th Edition 33
Decimal Addition Explanation 1 1 1 3 7 5 8 What just happened? 1 1 1 (carry) 3 7 5 8 + 4 6 5 7 8 4 1 5 + 4 6 5 7 8 14 11 15 (sum) 10 10 10 (subtract the base) 8 4 1 5 So when the sum of a column is equal to or greater than the base, we subtract the base from the sum, record the difference, and carry one to the next column to the left. Understanding Computers: Today and Tomorrow, 13 th Edition 34
Binary Addition Rules: – 0 + 0 = 0 – 0 + 1 = 1 – 1 + 0 = 1 (just like in decimal) n 1 + 1 = 210 = 102 = 0 with 1 to carry n 1 + 1 = 310 = 112 = 1 with 1 to carry Understanding Computers: Today and Tomorrow, 13 th Edition 35
Binary Addition Example 1: Add binary 110111 to 11100 1 1 + 1 1 0 1 1 1 0 0 1 1 Col 1) Add 1 + 0 = 1 Write 1 Col 2) Add 1 + 0 = 1 Write 1 Col 3) Add 1 + 1 = 2 (10 in binary) Write 0, carry 1 Col 4) Add 1+ 0 + 1 = 2 Write 0, carry 1 Col 5) Add 1 + 1 = 3 (11 in binary) Write 1, carry 1 Col 6) Add 1 + 0 = 2 Write 0, carry 1 Col 7) Bring down the carried 1 Write 1 Understanding Computers: Today and Tomorrow, 13 th Edition 36
Binary Addition Explanation What is actually happened when we carried in binary? In the first two columns, there were no carries. In column 3, we add 1 + 1 = 2 Since 2 is equal to the base, subtract the base from the sum and carry 1. 11 1 1 + 1 1 0 1 1 1 0 0 2 3 2 2 - 2 2 In column 4, we also subtract the base from the sum and carry 1. . 1 0 0 1 1 In column 5, we also subtract the base from the sum and carry 1. In column 6, we also subtract the base from the sum and carry 1. In column 7, we just bring down the carried 1 Understanding Computers: Today and Tomorrow, 13 th Edition 37
Binary Addition Verification You can always check your answer by converting the figures to decimal, doing the addition, and comparing the answers. + 1 1 0 1 1 1 0 0 Verification 1101112 5510 +0111002 + 2810 8310 64 32 16 8 4 2 1 1 0 0 1 1 = 64 + 16 + 2 +1 = 8310 1 0 0 1 1 Understanding Computers: Today and Tomorrow, 13 th Edition 38
Binary Addition Example 2: Add 1111 to 111010. 1 1 1 + 1 1 1 0 0 0 1 1 Verification 1110102 5810 +0011112 + 1510 7310 64 32 16 8 4 2 1 1 0 0 1 0 0 1 = 64 + 8 +1 = 7310 1 0 0 1 Understanding Computers: Today and Tomorrow, 13 th Edition 39
Decimal Subtraction Example (Borrow method) Subtract 4657 from 8025: 7 9 11 8 - 4 10 6 2 5 15 7 3 3 6 8 1) Try to subtract 5 – 7 can’t. Must borrow 10 from next column. Add the borrowed 10 to the original 5. Then subtract 15 – 7 = 8. 2) Try to subtract 1 – 5 can’t. Must borrow 10 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 10 to the original 0. Now you can borrow 10 from this column. Add the borrowed 10 to the original 1. . Then subract 11 – 5 = 6 3) Subtract 9 – 6 = 3 4) Subtract 7 – 4 = 3 Understanding Computers: Today and Tomorrow, 13 th Edition 40
Decimal Subtraction Explanation 8 0 - 4 6 3 3 2 5 5 7 6 8 §So when you cannot subtract, you borrow from the column to the left. §The amount borrowed is 1 base unit, which in decimal is 10. §The 10 is added to the original column value, so you will be able to subtract. Understanding Computers: Today and Tomorrow, 13 th Edition 41
Binary Subtraction Example 1: Subtract binary 11100 from 110011 2 1 0 0 2 2 - 1 1 0 0 1 01 1 1 Col 1) Subtract 1 – 0 = 1 Col 2) Subtract 1 – 0 = 1 Col 3) Try to subtract 0 – 1 can’t. Must borrow 2 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 2 to the 0 on the right. Now you can borrow from this column (leaving 1 remaining). Add the borrowed 2 to the original 0. Then subtract 2 – 1 = 1 Col 4) Subtract 1 – 1 = 0 Col 5) Try to subtract 0 – 1 can’t. Must borrow from next column. Add the borrowed 2 to the remaining 0. Then subtract 2 – 1 = 1 Col 6) Remaining leading 0 can be ignored. Understanding Computers: Today and Tomorrow, 13 th Edition 42
Binary Subtraction Verification Subtract binary 11100 from 110011: 2 1 0 0 2 2 - 1 1 0 0 1 1 1 0 0 Verification 1100112 5110 - 111002 - 2810 2310 64 32 16 8 4 2 1 0 1 1 1 = 16 + 4 + 2 + 1 = 2310 1 01 1 1 Understanding Computers: Today and Tomorrow, 13 th Edition 43
• Note X = (1151)10 , y = (1102)10 which one is greater than the other ? Ans. Compare each digit from left to right digit 1 in x = digit 1 in y goto the next digit 2 in x = digit 2 in y goto the next digit 3 in x > digit 3 in y stop x greater than y Quiz: (110101)2 , (11001)2 which one is greater than the other ? Understanding Computers: Today and Tomorrow, 13 th Edition 44
Binary multiplication • Binary multiplication uses the same technique as decimal multiplication. • Example: multiplying 1102 by 102. 110 x 10 ---- 000 + 110 -------1100 6 x 2 -----12 Understanding Computers: Today and Tomorrow, 13 th Edition 45
Division • Division rule – Set quotient to zero – Repeat while dividend is greater than or equal to divisor • Subtract divisor from dividend • Add 1 to quotient – End of repeat block – quotient is correct, dividend is remainder – STOP Understanding Computers: Today and Tomorrow, 13 th Edition 46
Binary division • Division as repeated subtraction Example in decimal 84 ÷ 21 = ? ? I subtracted 21 four times, 84 − 21 so 84 ÷ 21 = 4 ------ 63 − 21 ------- 42 − 21 ----- 21 − 21 ------- 0 Understanding Computers: Today and Tomorrow, 13 th Edition 1 1 ---4 47
• Example: Find 1100 ÷ 0101 quotient • Ans. 0 1100 - 0101 = 111 -101= 010 1 1 ----2 Hence result is 2 and with remainder 2 ( (10)2 ) Understanding Computers: Today and Tomorrow, 13 th Edition 48
ONE’S COMPLEMENT AND TWO’S COMPLEMENT REPRESENTATIONS Understanding Computers: Today and Tomorrow, 13 th Edition
One’s Complement Representation • The one’s complement of a binary number involves inverting all bits. • 1’s comp of 0011 is 1100 • 1’s comp of 1010 is 0101 Understanding Computers: Today and Tomorrow, 13 th Edition
Two’s Complement • Algorithm 1 – Simply complement each bit and then add 1 to the result. – Finding the 2’s complement of (01100101)2 and of its 2’s complement… N = 01100101 [N] = 10011011 10011010 01100100 + 1 -------- 10011011 01100101 Understanding Computers: Today and Tomorrow, 13 th Edition
Two’s Complement Representation Algorithm 2 – Starting with the least significant bit, copy all of the bits up to and including the first 1 bit and then complementing the remaining bits. N = 0 1 1 0 0 1 [N] = 1 0 0 1 1 Understanding Computers: Today and Tomorrow, 13 th Edition
LOGICAL OPERATION ON BINARY Understanding Computers: Today and Tomorrow, 13 th Edition
Logical OR Rules OR Operations • OR Results in 1 if either or both of the operands are 1. • OR Table 0 OR 0 = 0 0 OR 1 = 1 1 OR 0 = 1 1 OR 1 = 1 Understanding Computers: Today and Tomorrow, 13 th Edition 54
Logical OR Operation To perform the OR operation, take one column at a time and perform the OR operation using the OR table. Ex 1: 1 0 0 1 1 OR 0 0 1 1 1 Understanding Computers: Today and Tomorrow, 13 th Edition 55
Logical XOR Rules XOR Operations • The exclusive OR. Similar to OR except that it now gives 0 when both its operands are 1. Rules. 0 XOR 0 = 0 0 XOR 1 = 1 1 XOR 0 = 1 1 XOR 1 = 0 Understanding Computers: Today and Tomorrow, 13 th Edition 56
Logical XOR Examples Ex 1: 1 0 0 1 XOR 0 0 1 1 1 0 0 1 1 0 Ex 2: 0 1 1 1 XOR 0 0 1 0 0 1 Understanding Computers: Today and Tomorrow, 13 th Edition 57
Logical AND Rules AND Operations • AND yields 1 only if both its operands are 1. Rules. 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1 Understanding Computers: Today and Tomorrow, 13 th Edition
Logical AND Examples Ex 1: 1 1 0 0 1 1 AND 0 0 1 1 0 0 0 1 1 Ex 2: 0 1 1 1 AND 1 0 0 1 0 0 0 1 Understanding Computers: Today and Tomorrow, 13 th Edition
Logical NOT Operations • NOT is a separate operator flipping the bits. Rules. NOT 0 = 1 NOT 1 = 0 Example. NOT 1 0 = 0 1 Understanding Computers: Today and Tomorrow, 13 th Edition
THANK YOU Understanding Computers: Today and Tomorrow, 13 th Edition
- Understanding computers today and tomorrow
- Tomorrow creeps in this petty pace
- Tomorrow and tomorrow and tomorrow kurt vonnegut analysis
- Due tomorrow do tomorrow
- Due tomorrow do tomorrow
- How you use ict today and how you will use it tomorrow
- Computer today and tomorrow
- Find the 2’s complement number for 001101110
- Same today tomorrow and forever
- Marketing today and tomorrow chapter 1
- Agriculture- yesterday today and tomorrow
- I am a flower quickly fading here today and gone tomorrow
- Monkey and peaches problem answer
- Learn today lead tomorrow
- Ute prayer earth teach me
- Students today leaders tomorrow
- Nursing now today's issues tomorrow's trends
- Recycle today for a better tomorrow
- Don't put till tomorrow what you can do today
- Little bunny hopping through the forest
- Work today get paid tomorrow
- Where today meets tomorrow
- A dollar today is worth more than a dollar tomorrow
- Royal family yesterday today is tomorrow
- A dollar today is worth more tomorrow
- Nursing now today's issues tomorrow's trends
- Creating a better tomorrow today
- Computer applications - understanding computers unit
- Impact of computer on business
- The ultimate ancestor of today's computer
- Computers are your future 12th edition pdf
- For today's meeting
- Todays class
- Meeting objective
- Today lesson or today's lesson
- Today's lesson or today lesson
- Example of repitition
- Understanding nutrition 13th edition rental
- Copyright
- Understanding human differences 5th edition
- Understanding earth 7th edition
- Covergent boundary
- Understanding earth 5th edition
- Adler and rodman 2006
- Business essentials 12th edition free
- Adler and rodman 2006
- Earth 6th edition
- Linear vs relational worldview
- Business communication today 14th edition pdf
- Criminology today 7th edition
- Mis chapter 6
- Zulily case study
- Romeo and juliet act 3 themes
- Tomorrow's technology and you
- Tomorrow's technology and you
- Tomorrow's technology and you
- Computers make the world smaller and smarter answers
- Chapter 12 computers and technology in health care
- Control flow and data flow computers
- Words related to computers and the internet
- Chapter 1 introduction to computers and programming
- Computers make the world smaller and smarter