1 / 34

Binary

Binary. Negative Integers. Negative Integers. Sign and magnitude One’s complement Two’s complement Binary Coded Decimal (BCD). Sign and Magnitude. The method used in decimal to represent negative numbers is sign and magnitude. - 25 Sign Magnitude/value

Télécharger la présentation

Binary

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. Binary Negative Integers

  2. Negative Integers • Sign and magnitude • One’s complement • Two’s complement • Binary Coded Decimal (BCD)

  3. Sign and Magnitude • The method used in decimal to represent negative numbers is sign and magnitude. - 25 Sign Magnitude/value • This system is available in decimal where: 1 ≡ negative sign

  4. Sign and Magnitude • The method is as follows: • Convert the value or magnitude to binary and represent using eight or ten bits or as you are instructed • Change the leftmost bit to 1 if the number is negative

  5. Example: • Represent the following decimal as binary, using sign and magnitude: • NEGATIVE 1010 • NEGATIVE 2510

  6. -10 to Binary using 8 bit Sign and Magnitude • Convert 10 to binary • 1010 • Use 8 bits to represent • 00001010 • Change to negative: • 10001010 • -1010=100010102

  7. -25 to Binary using 8 bit Sign and Magnitude • Convert 25 to binary • 11001 • Use 8 bits to represent • 00011001 • Change to negative: • 10011001 • -2510=100110012

  8. One’s Complement • The method is as follows: • Convert the value or magnitude to binary and represent using eight or ten bits or as you are instructed • Find the complement by changing all the 0’s to 1’s and all the 1’s to 0’s

  9. Example: • Represent the following decimal as binary, using ONE’S COMPLEMENT: • NEGATIVE 1010 • NEGATIVE 2510

  10. -25 to Binary using 8 bit One’s Complement • Convert 25 to binary • 11001 • Use 8 bits to represent • 00011001 • Change to negative: 1 0 and; 0 1 • 11100110 • -2510=111001102

  11. Two’s Complement • The method is as follows: • Convert the value or magnitude to binary and represent using eight or ten bits or as you are instructed • Find the One’s complement by changing all the 0’s to 1’s and all the 1’s to 0’s • Add one to the new value

  12. Example: • Represent the following decimal as binary, using TWO’S COMPLEMENT: • NEGATIVE 1010 • NEGATIVE 2510

  13. -25 to Binary using 8 bit Two’s Complement • Convert 25 to binary • 11001 • Use 8 bits to represent • 00011001 • Find one’s complement • 11100110 • Add one to the answer • 11100110+1 • -2510=111001112

  14. Binary Coded Decimal B.C.D.

  15. Format • Each digit is converted separately using four (4) bits each. 25 0010 0101

  16. Format • Decimal positioning is kept 25 = 0010 0101 2 10

  17. Negative BCD • Use Sign and Magnitude where the signs are: + Positive = 1110 2 - Negative = 1111 2

  18. Positive and Negative +25 = 11100010 0101 2 -25 = 11110010 0101 2

  19. Steps: • Convert each digit to binary • Write sign (if necessary) • Write answer in decimal order Convert the following numbers from decimal to binary using BCD format: 10 250 43 11 54 -10 +250 -43 +11 -54

  20. Binary Real Numbers

  21. Real Numbers • Real numbers are numbers containing fractions. • There are two ways real numbers are represented in binary. • They are: • Fixed-point numbers • Floating-point numbers

  22. Fixed-point Numbers • Decide the number of places after the point because the point is not stored among the digits. • Convert the whole number to binary • Convert the fraction to binary: • Multiply the fraction by two and record the any resulting whole number • Repeat until you get the set amount of places after the point

  23. Fixed-point Numbers • Convert 4.210 to binary with 4 places after the point. • The answer is therefore:10000112

  24. Floating-point Numbers • The number of places after the point varies. • Data is represented in the following parts: • A sign • A fractional part (example 0.345) or mantissa • The base • An exponent

  25. Standard Form • Change to standard form: • 345 • -45.6

  26. Floating-point Numbers • Decimal Example: • This is equal to writing a number in standard form 3 345 = 0.345 x 10 Exponent Sign Mantissa base 2 -45.6 = -0.456 x 10

  27. Floating-point Numbers • Binary Example: Binary number 11111010 • The mantissa is a binary fraction • The sign bit : 1 for negative and 0 for positive • This exponent uses sign and magnitude

  28. Floating-point Numbers • IEEE Standard uses 32 and 64bits, but for simplicity we will use only 8 bits as follows: • The sign – 1 bit • 1 means negative; 0 means positive • The Exponent – 3 bits • Sign and magnitude. Leftmost bit is the sign • The Mantissa – 4 bits • A fraction

  29. Convert the decimal to binary (maintain the whole and fraction parts). Normalise the mantissa Convert the resulting exponent Insert the sign bit Write the number in SEM format 3 ¾ to binary retaining decimal format: 11.11 Normalised mantissa as if in standard form: .1111x22 The exponent : 2 = 011 The number is positive, so the sign = 0 RESULT:0 011 11112 From Decimal: 3¾

  30. Let us Calculate: • Binary Example: 111110102 • The mantissa : 0.625 • The sign bit : - (negative) • The exponent : -3 • RESULT: - 0.1010 X 2-3 = 0.5 + 0.125

  31. Let us Calculate: • Binary Example: 111110102 • The mantissa is: 0.625 • The sign bit : - (negative) • The exponent : -3 • RESULT: - 0.1010 X 2-3 = -0 0 0 0.1 0 1 0 =-0.00012 = - 0.062510

  32. Characters • ASCII (American Standard Code of Information Interchange) • EBCDIC (Extended Binary Coded Decimal Interchange Code

  33. Parity Bit • To maintain data integrity a special signal bit is sometimes used. This is a parity bit. Instead of the regular eight bits that make up the byte, nine bits are used. • If he number of “1” bits is odd then the parity is set to 1 so that the number of 1”s is always even • If the number of “1” bits is even the parity is set to “0”.

  34. The END

More Related