Negative and Fractional number representation
Negative and Fractional Number Representation
What are Rational Numbers?
Rational numbers are numbers that can be expressed as the quotient of two integers, where the denominator is not zero. For example, and are rational numbers.
Negative Rational Numbers
Negative rational numbers are rational numbers that are less than zero. They can be represented as the quotient of two integers where either the numerator or the denominator is negative, but not both. For example:
-9/5 - Representation of negative rational numbers on a number line is very similar to the representation of negative integers or negative fractions on a number line. The left-hand side of 0 on a number line represents the negative region and the right-hand side of 0 represents the positive region.
Representation on a Number Line
Negative rational numbers can be represented on a number line. If we take zero as the central point, positive rational numbers lie to the right of zero, and negative rational numbers lie to the left. The further left a negative rational number is, the smaller its value.
For instance:
is to the left of zero.
is further left than .
Negative Numbers in Binary
Negative numbers can be represented in binary using several methods, but the most common one is Two's Complement. Here's how it works:
Positive to Binary: Start with the binary representation of the positive version of the number.
Invert the Bits: Change all 0s to 1s and all 1s to 0s (this is called the One's Complement).
Add One: Add 1 to the result from step 2.
For example, to represent -5 in an 8-bit system:
Positive 5 in binary is
00000101
.Inverting the bits gives
11111010
.Adding 1 gives
11111011
.
So, 11111011
is the two's complement representation of -5.
Fractional Numbers in Binary
Fractional numbers can be represented in binary using a method similar to decimal fractions:
The part before the binary point (like the decimal point) is handled as an integer.
The part after the binary point represents fractions, where each position is a negative power of 2.
For example, let's represent 5.625 in binary:
Whole Number Part: 5 in binary is
101
.Fractional Part:
0.625 in binary:
0.5 (2^-1) + 0.125 (2^-3)
So, 0.625 in binary is
0.101
.
Combining these gives 101.101
for 5.625.
Negative Fractional Numbers
Combining both concepts:
Positive Representation: Start with the binary representation of the positive number.
Two's Complement: Apply the two's complement method to the entire number, including the fractional part.
For instance, to represent -5.625:
Positive 5.625 in binary is
101.101
.Invert the bits:
010.010
.Add 1 to the least significant bit:
010.011
.
Therefore, 11010.011
(as we have to consider enough bits for an 8-bit system or more) would be the two's complement representation of -5.625.
Negative Numbers in Binary
Negative numbers are often represented in binary using Two's Complement. Here's the process:
Positive Binary Representation: Start with the binary representation of the positive version of the number.
Invert the Bits: Change all 0s to 1s and all 1s to 0s (this is called the One's Complement).
Add One: Add 1 to the result from step 2.
For example, to represent -7 in an 8-bit system:
Positive 7 in binary is
00000111
.Inverting the bits gives
11111000
.Adding 1 gives
11111001
.
So, 11111001
is the two's complement representation of -7.
Fractional Numbers in Binary
Fractional numbers in binary are represented using a method similar to decimal fractions:
The part before the binary point (like the decimal point) is handled as an integer.
The part after the binary point represents fractions, where each position is a negative power of 2.
For example, let's represent 6.375 in binary:
Whole Number Part: 6 in binary is
110
.Fractional Part:
0.375 in binary:
0.25 (2^-2) + 0.125 (2^-3)
So, 0.375 in binary is
0.011
.
Combining these gives 110.011
for 6.375.
Negative Fractional Numbers
For negative fractional numbers, we combine both concepts:
Positive Representation: Start with the binary representation of the positive number.
Two's Complement: Apply the two's complement method to the entire number, including the fractional part.
For instance, to represent -6.375:
Positive 6.375 in binary is
110.011
.Invert the bits:
001.100
.Add 1 to the least significant bit:
001.101
.
Therefore, 11111001.101
(considering it in a larger bit system) would be the two's complement representation of -6.375.
SUMMERY
Negative numbers in binary are represented using the Two's Complement method, which involves inverting the bits of the positive binary representation and then adding one. Fractional numbers are represented in binary by converting the integer part to binary and the fractional part into a series of binary fractions, where each position is a negative power of 2. When it comes to negative fractional numbers, we combine both approaches by first converting the number to binary, then applying the Two's Complement method to the entire binary representation.
Comments
Post a Comment