Professional Documents
Culture Documents
Fop Presentation Group 3 Updated
Fop Presentation Group 3 Updated
Group 3
NEGATIVE NUMBERS IN BINARY
Negative
number is represented into binary by the
method called Two’s complement
The two's complement method is a way to represent
negative numbers in binary form. In this method, the
most significant bit (leftmost bit) is used to indicate the
sign of the number, where 0 represents a positive
number and 1 represents a negative number.
HOW TO REPRESENT A NEGATIVE NUMBER
USING TWO’S METHOD🤔??
In a binary number system, the leftmost bit, also known as the
most significant bit (MSB), carries the sign information. If the
MSB is 0, the number is positive, while if it's 1, the number is
negative.
To obtain the two's complement representation of a negative
number, we follow these steps:
1. Start with the positive binary representation of the number.
2. Invert (flip) all the bits, changing 0s to 1s and vice versa.
3. Add 1 to the resulting binary number.
EXAMPLE OF HOW TO CONVERT
NEGATIVE NUMBER INTO BINARY
Let's illustrate this process with an example using an 8-bit
system. Suppose we want to represent -10 in binary:
1. Start with the positive binary representation of 10:
00001010.
2. Invert all the bits: 11110101.
3. Add 1 to the inverted number: 11110110.
The resulting binary representation, 11110110, is the two's
complement representation of -10 in an 8-bit system.
NOTE THAT
These are some example in order to have deep understanding about negative
number representation into binary.
This picture will help you to understand two’s complement method.
Point/comma handling in binary
Consider the unsigned integer 23 (binary: 00010111) and perform a right shift
by 2 positions.
1. Binary Representation: 23 is already in binary form as 00010111.
2. Shift Amount: We want to shift by 2 positions.
3. Right Shift Operation:
First Shift:
Start with: 00010111
Shift right by 1: 00001011
Second Shift:
Start with: 00001011
Shift right by 1: 00000101
4. Interpret the Result: The final binary representation after two right shifts is
00000101, which is equal to the decimal number 5.
NOTES TO TAKE WHEN DEALING WITH
RIGHT SHIFT OF BINARY NUMBERS
The number of positions to shift should be a non-negative integer
The sign bit is preserved during the shift operation.
The vacant bit positions on the left are filled with copies of the sign bit.
The right shift operation is equivalent to dividing the number by 2 raised to the power
of the number of positions shifted.
Signed values range (characters &
integers short long)
The signed values range for characters, integers (int), short integers (short), and long
integers (long) refers to the range of values that can be represented by these data types
while taking into account both positive and negative numbers.
Signed characters