# Binary Negative Integers.

## Presentation on theme: "Binary Negative Integers."— Presentation transcript:

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 This system is available in decimal where: 1 ≡ negative sign

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

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

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

-25 to Binary using 8 bit Sign and Magnitude
Convert 25 to binary 11001 Use 8 bits to represent Change to negative: -2510= 2 25 Remainder 12 1 6 3

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

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

-25 to Binary using 8 bit One’s Complement
Convert 25 to binary 11001 Use 8 bits to represent Change to negative: 1 0 and; 0 1 -2510= 2 25 Remainder 12 1 6 3

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

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

-25 to Binary using 8 bit Two’s Complement
Convert 25 to binary 11001 Use 8 bits to represent Find one’s complement Add one to the answer -2510= 2 25 Remainder 12 1 6 3 1 +

Binary Coded Decimal B.C.D.

Format Each digit is converted separately using four (4) bits each. 25
Remainder 1 2= 0010 25 2 5 Remainder 1 5=0101 0010 0101

Format Decimal positioning is kept 25 = 0010 0101 2 10

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

Positive and Negative +25 = 0101 2 -25 = 0101 2

Convert the following numbers from decimal to binary using BCD format:
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:

Binary Real Numbers

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

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

Fixed-point Numbers Convert to binary with 4 places after the point. The answer is therefore: 2 4 R 1 =100 0.2 x 2 = 0.4 0.4 x 2 0.8 0.8 x 2 1.6 0.6 x 2 1.2 =0011

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

Standard Form Change to standard form: 345 -45.6

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

Floating-point Numbers
Binary Example: Binary number The mantissa is a binary fraction The sign bit : 1 for negative and 0 for positive This exponent uses sign and magnitude 1 111 1010 Sign Exponent Mantissa

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

From Decimal: 3¾ 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:

Let us Calculate: Binary Example: 111110102 The mantissa : 0.625
The sign bit : - (negative) The exponent : -3 RESULT: X 2-3 2-1 2-2 2-3 2-4 1 .5 0.125 1 111 1010 Sign Exponent Mantissa - -3 0.625 =

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

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

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”.

The END