1 / 71

Objectives

Objectives . Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn how numbering systems are used to count Understand the significance of positional value in a numbering system

anaya
Download Presentation

Objectives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objectives • Learn why numbering systems are important to understand • Refresh your knowledge of powers of numbers • Learn how numbering systems are used to count • Understand the significance of positional value in a numbering system • Learn the differences and similarities between numbering system bases

  2. Objectives (continued) • Learn how to convert numbers between bases  • Learn how to do binary and hexadecimal math  • Learn how data is represented as binary in the computer  • Learn how images and sounds are stored in the computer

  3. Why You Need to Know About...Numbering Systems • Computers store programs and data in binary code • Understanding of binary code is key to machine • Binary number system is point of departure • Hexadecimal number system • Provides convenient representation • Written into error messages

  4. Powers of Numbers - A Refresher • Raising a number to a positive power (exponent) • Self-multiply the number by the specified power • Example: 23 = 2 * 2 * 2 = 8 (asterisk = multiplication) • Special cases: 0 and 1 as powers • Any number raised to 0 = 1; e.g, 10,5550 = 1. • Any number raised to 1 = itself; e.g., 10,5551 = 10,555

  5. Powers of Numbers -A Refresher (continued) • Raising a number to a negative power • Follow same steps for positive power • Divide result into 1; e.g., 2-3 = 1/ (23) = .125

  6. Counting Things • Numbers are used to count things • Base 10 (decimal) most familiar • The computer uses base 2, called binary • Base 2 has two unique digits: 0 and 1

  7. Base 10 4 2 . 5 6 4  10 + 2  1 + 5  0.1 + 6  0.01 4  101+ 2  100 + 5  10- 1+ 6  10-2 • Example 12: • Express Decimal 42.56 using radix of 10.

  8. Counting binary numbers

  9. BinarytoDecimal Conversion • Any binary number can be converted to decimal by multiplying the weight of each position with the binary digit and adding together. • Binary number 1 0 1 1 0 • Power of 2 position 24 + 23 + 22 + 21 + 20 • (241) + (230) + (221) + (211) + (20 0) • Decimal value 16 + 0 + 4 + 2 + 0 • = 2210

  10. Examples • Convert the following Binary numbers to its equivalent Decimal number. • (i) 10110 • (ii) 110101 • (iii) 111001.0101 • (iv) 111111.111

  11. Decimal–to–Binary Conversion • The most convenient method is called division by 2 method. • In which first decimal number will be divided by 2. • The quotient will be dividend for the next step. • In each step the remainder part will be recorded separately. • The 1st remainder of the 1st division will be the LSB in the binary number. • The quotient should repeatedly divide by 2 until the quotient becomes 0. • The final remainder will be the MSB in binary number.

  12. Decimal–to–Binary Conversion 2 20 + remainder of 0 2 10 + remainder of 0 2 5 + remainder of 1 2 2 + remainder of 0 2 2 + remainder of 1 0 1 0 0 1 0 02

  13. Converting a decimal fractional number to its binary the decimal fractional part will be multiply by 2 till the fractional part gets 0 or till the number of decimal places reached. MSB • 0.252 = 0.50 LSB 0.5 2 = 1.00 . 0 1 0.2510 = . 012

  14. Examples • Convert the following Decimal numbers to its equivalent Binary number. • (i) 47 • (ii) 254 • (iii) 12.5 • (iv) 341.58

  15. Binary Addition • Adding of two binary numbers follows same as addition of two decimal numbers. • Sum Carryout • Rule 1 0 + 0 = 0 0 • Rule 2 0 + 1 = 1 0 • Rule 3 1 + 0 = 1 0 • Rule 4 1 + 1 = 0 1

  16. Binary Addition • Procedure for adding numbers similar in all bases • Difference lies in carry process • Value of carry = value of base • Example: 1011 • +1101 • 11000 • Carry value for above = 102 = (1 x 101 + 0 x 100 ) = 210 • Procedure for subtraction, multiplication, and division also similar

  17. Examples • . Perform the following binary addition. • (i) 1011 + 0101 • (ii) 111101 +010110 • (iii) 11101.01 +1010.110

  18. Binary Subtraction • When subtracting one binary number A(subtrahend) from another binary number B(Minuend) where B > A, the answer is called the difference. There are four basic rules that should be followed in binary subtraction • Minuend (B) Subtrahend (A) Difference Borrow out • Rule 1 0  0 = 0 • Rule 2 0  1 = 1 with a borrow of 1 • Rule 3 1  0 = 1 • Rule 4 1  1 = 0

  19. Binary Subtraction

  20. Examples • Perform the following binary subtraction. • (i) 110 – 010 • (ii) 1110-0111 • (iii) 110001-01111

  21. HEXADECIMAL NUMBER SYSTEM • Hexadecimal number system is called as base 16 number system and it uses 10 decimal numbers and 6 alphabetic characters to represent all 16 possible symbols.

  22. Converting To Base 10 • Three methods: • Table look-up (more extensive than Table 4-1) • Calculator • Algorithm for evaluating number in any base • Example: consider 169AE in base 16 • Identify base: 16 • Map positions to digits: 43210 • Raise, multiply and add: 169AE = (1 x 164) + (6 x 163) + (9 x 162) + (10 x 161) + (14 x 160) = 92,590

  23. Examples • Convert the following Hexadecimal numbers to its equivalent Decimal number • (i) 79 • (ii) 6A.9 • (iii) AB4.95C • (iv) ABDC.FFC

  24. Converting From Base 10 • Three methods: • Table look-up (more extensive than Table 4-1) • Calculator

  25. Converting From Base 10 (continued) • Algorithm for converting from base 10 • Divide the decimal number by the number of the target base (for example, 2 or 16) • Write down the remainder • Divide the quotient of the prior division by the base again • Write the remainder to the left of the last remainder written • Repeat Steps 3 and 4 until the whole number result is 0

  26. Converting From Base 10 (continued) • Practice conversion algorithm: find hexadecimal equivalent of decimal 45 • Divide 45 by 16 (base) • Write down remainder D • Divide 2 by 16 • Write down remainder 2 to the left of D (2D) • Stop since reduced quotient = 0 • Check: 2D = (2 x 161) + (13 x 160) = 32 + 13 = 45

  27. Examples • Convert the following Decimal numbers to its equivalent Hexadecimal number • (i) 67 • (ii) 195.67 • (iii) 597.96 • (iv) 1022.5845

  28. HexadecimaltoBinary Conversion • Hexadecimal number can be represent in binary form by using 4 bits for each hexadecimal number. • 016 can be written in binary – 0000 • 716 in binary can be written – 0111 • A16 in binary can be written – 1010

  29. Examples • Convert the following Hexadecimal numbers to its equivalent Binary number. • (i) 6F • (ii) 5ABD • (iii) 8A.D9 • (iv) 9FFF.FEC

  30. BinarytoHexadecimal Conversion • This is the reverse form of the hexadecimal to binary conversion. First the binary number should be divided into group of four bits from the LSB. Then each four-bit binary number is converted to a hexadecimal form

  31. Examples • Convert the following binary number to its equivalent Hexadecimal number. • (i) 11010101 • (ii) 1011101010 • (iii) 10110101.001010

  32. Hexadecimal Addition • The addition in hexadecimal is same as in binary addition. The largest single digit in octal is 15. If the result of A + B is greater then 15, then we must subtract 16 (the base) and carry 1 to the next digit. • Lets look some how to do additions in octal • 016 + 416 = 410 = 416 • 416 + B16 = 1410 = E16 • 416 + C16 = 1610 >15 Subtract 16 and carry 1 =1016

  33. Examples • Perform the following Additions in Hexadecimal. • (i) 948 + A39 • (ii) ABD6 + 9FFE • (iii) ABCD.9F + 99FF.FE

  34. Counting Things (continued) • Hexadecimal system used to represent binary digits • Base 16 has sixteen unique digits: 0 – 9, A - F • Counting for all number systems similar • Count digits defined in number system until exhausted • Place zero in ones column. Carry one to the left

  35. DATA REPRESENTATION Binary representation Unsigned Signed One's complement Two's complement Signed magnitude • Binary numbers can be stored in two different formats : • Unsigned numbers • Signed numbers

  36. Integer Representation • To represent an integer in fixed point representation the radix point is fixed. For example, a 8 bit register can hold at the maximum of 8 bits and a 16 bit register can hold 16 bits.

  37. UNSIGNED NUMBERS • If a number is represented in unsigned, it is assumed to be positive. So it is not necessary to indicate the sign bit. All the bits including the sign bit is used to store the magnitude. Example 3–1 Represent the decimal number 52 in 16 bit unsigned representation Solution The binary form of 52 is 110100. Note that the number of bits for the binary number 52 is only 6. Fill the empty positions (10 positions) on the left with zeros as 0000000000110100.

  38. SIGNED NUMBERS • Signed numbers can be represented in any one of the following ways : Signed magnitude • One’s (1’s) Complement • Two’s (2’s) Complement

  39. Signed Magnitude Representation • In signed magnitude, the MSB is reserved for sign. If the MSB is 0 then the number is positive. If the number is negative, then the MSB will be set to 1. • Reserving the sign bit will restricts the maximum range of the values. • For example, if the storage is 8 bit, only 7 bits are used for magnitude (0-6). The MSB is reserved for the sign bit (7th bit). • If the system uses a 8 bit storage, then the range is from -127 to +127 (11111111 to 01111111).

  40. Signed Magnitude • The following procedure is followed to represent a decimal number in signed magnitude: • Temporarily ignore the sign of the given decimal number. • Convert the absolute value (magnitude) of the number into its binary equivalent. • Fill in the empty positions on the left with zeros except MSB. • Check the sign of the given decimal number. If the number is positive fill the MSB with 0. If the number is negative fill the MSB with 1.

  41. Signed Magnitude • Example 3–2 Represent the decimal number +15 in 8 bit signed magnitude representation • Solution The absolute value of the given decimal number is 15. The binary equivalent of the decimal number 15 is 1111. Fill in the empty positions on the left with zeros except MSB is 0001111. The sign of the given number is positive. Hence, fill in the MSB as 0, which gives 00001111is the result.

  42. Signed Magnitude • Example 3–3 Represent the decimal number –15 in 8 bit signed magnitude representation • Solution The absolute value of the given decimal number is 15. The binary equivalent of the decimal number 15 is 1111. Fill in the empty positions on the left with zeros except MSB is 0001111. The sign of the given number is positive. So fill in the MSB as 1, which gives 10001111is the result.

  43. Examples • Convert the following decimal numbers to their 8bit sing binary format • (i) +36 • (ii) -69 • (iii) +95 • (iv) –120

  44. One’s (1’s) Complement Representation • The following procedure is followed to represent a decimal number in 1’s complement representation: • Temporarily ignore the sign of the given decimal number • Convert the absolute value (magnitude) of the number into its binary equivalent • Fill all the empty positions on the left with zeros including MSB • Check the sign of the given decimal number. If the number is positive stop the process and the number obtained in the third step is the result. If the number is negative, then complement the digits as 0 to 1 and 1 to 0

  45. One’s (1’s) Complement Representation • Example 3–4 Represent +15 in 1’s complement representation using 8 bit storage • Solution The magnitude of the given decimal number is 15. The binary equivalent of the decimal number 15 is 1111. Fill all the empty positions on the left with zeros including MSB as 00001111. The sign of the given number is positive. Hence, 1’s complement representation of the given number +15 is 00001111.

  46. One’s (1’s) Complement Representation • Example 3–5 Represent –15 in 1’s complement representation using 8 bit storage • Solution The absolute value of the given decimal number is 15. The binary equivalent of the decimal number 15 is 1111. Fill all the empty positions on the left with zeros including MSB as 00001111. The sign of the given number is negative. Therefore, complement the number which has been obtained in third step. The resultant representation is 11110000.

  47. Examples • Represent the following numbers in their 1s complement representation. • (i) +76 • (ii) –90 • (iii) –105 • (iv) -124

  48. Two’s (2’s) Complement Representation • In 2’s complement representation the MSB is reserved for sign bit. • The following procedure is followed to represent a decimal number in 2’s complement representation: • Temporarily ignore the sign of the given decimal number. • Convert the absolute value of the number into its binary equivalent. • Fill all the empty positions on the left with zeros including MSB. • Check the sign of the given decimal number. If the number is positive stop the process and the number obtained in the third step is the result. If the number is negative, then complement the digits as 0 to 1 and 1 to 0. After inverting the individual digits add 1 to LSB. If adding 1 result in a carry from the MSB, that carry is dropped.

More Related