Presentation is loading. Please wait.

Presentation is loading. Please wait.

Binary Negative Integers. Sign and magnitudeSign and magnitude Ones complementOnes complement Twos complementTwos complement Binary Coded Decimal (BCD)Binary.

Similar presentations


Presentation on theme: "Binary Negative Integers. Sign and magnitudeSign and magnitude Ones complementOnes complement Twos complementTwos complement Binary Coded Decimal (BCD)Binary."— Presentation transcript:

1 Binary Negative Integers

2 Sign and magnitudeSign and magnitude Ones complementOnes complement Twos complementTwos complement Binary Coded Decimal (BCD)Binary Coded Decimal (BCD)

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

4 Sign and Magnitude The method is as follows: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:Represent the following decimal as binary, using sign and magnitude: –NEGATIVE –NEGATIVE 25 10

6 -10 to Binary using 8 bit Sign and Magnitude Convert 10 to binary 1010 Use 8 bits to represent Change to negative: = Remainder

7 -25 to Binary using 8 bit Sign and Magnitude Convert 25 to binary Use 8 bits to represent Change to negative: = Remainder

8 Ones Complement The method is as follows: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 0s to 1s and all the 1s to 0s

9 Example: Represent the following decimal as binary, using ONES COMPLEMENT:Represent the following decimal as binary, using ONES COMPLEMENT: –NEGATIVE –NEGATIVE 25 10

10 -25 to Binary using 8 bit Ones Complement Convert 25 to binary Use 8 bits to represent Change to negative: 1 0 and; = Remainder

11 Twos Complement The method is as follows: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 Ones complement by changing all the 0s to 1s and all the 1s to 0s –Add one to the new value

12 Example: Represent the following decimal as binary, using TWOS COMPLEMENT:Represent the following decimal as binary, using TWOS COMPLEMENT: –NEGATIVE –NEGATIVE 25 10

13 -25 to Binary using 8 bit Twos Complement Convert 25 to binary Use 8 bits to represent Find ones complement Add one to the answer = Remainder

14 Binary Coded Decimal

15 Format Each digit is converted separately using four (4) bits each.Each digit is converted separately using four (4) bits each. 22Remainder = Remainder =0101

16 Format Decimal positioning is keptDecimal positioning is kept

17 Negative BCD Use Sign and Magnitude where the signs are:Use Sign and Magnitude where the signs are:

18 Positive and Negative

19 Steps: Convert each digit to binaryConvert each digit to binary Write sign (if necessary)Write sign (if necessary) Write answer in decimal orderWrite answer in decimal order Convert the following numbers from decimal to binary using BCD format:

20 Binary Real Numbers

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

22 Fixed-point Numbers Decide the number of places after the point because the point is not stored among the digits.Decide the number of places after the point because the point is not stored among the digits. Convert the whole number to binaryConvert the whole number to binary Convert the fraction 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 to binary with 4 places after the point.Convert to binary with 4 places after the point. The answer is therefore: The answer is therefore: R = x 2= x 2= x 2= x 2=1.2 =0011

24 Floating-point Numbers The number of places after the point varies.The number of places after the point varies. Data is represented in the following parts: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:Change to standard form:

26 Floating-point Numbers Decimal Example:Decimal Example: This is equal to writing a number in standard formThis is equal to writing a number in standard form

27 Floating-point Numbers Binary Example: Binary number Binary Example: Binary number The mantissa is a binary fractionThe mantissa is a binary fraction The sign bit : 1 for negative and 0 for positiveThe sign bit : 1 for negative and 0 for positive This exponent uses sign and magnitudeThis exponent uses sign and magnitude S Sign E Exponent M Mantissa

28 Floating-point Numbers IEEE Standard uses 32 and 64bits, but for simplicity we will use only 8 bits as follows: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 positive1 means negative; 0 means positive –The Exponent – 3 bits Sign and magnitude. Leftmost bit is the signSign and magnitude. Leftmost bit is the sign –The Mantissa – 4 bits A fractionA fraction

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

30 Let us Calculate: Binary Example: Binary Example: The mantissa : 0.625The mantissa : The sign bit : - (negative)The sign bit : - (negative) The exponent : -3The exponent : -3 RESULT: X 2 -3RESULT: X SignExponentMantissa =

31 Let us Calculate: Binary Example: Binary Example: The mantissa is: 0.625The mantissa is: The sign bit : - (negative)The sign bit : - (negative) The exponent : -3The exponent : -3 RESULT: X 2 -3RESULT: X 2 -3 = = =

32 Characters ASCII (American Standard Code of Information Interchange)ASCII (American Standard Code of Information Interchange) EBCDIC (Extended Binary Coded Decimal Interchange CodeEBCDIC (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.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 1s is always evenIf he number of 1 bits is odd then the parity is set to 1 so that the number of 1s is always even If the number of 1 bits is even the parity is set to 0.If the number of 1 bits is even the parity is set to 0.

34 The END


Download ppt "Binary Negative Integers. Sign and magnitudeSign and magnitude Ones complementOnes complement Twos complementTwos complement Binary Coded Decimal (BCD)Binary."

Similar presentations


Ads by Google