Unit-IV; Professional Sales Representative (PSR).pptx
Representation of Signed Numbers - R.D.Sivakumar
1. R.D.SIVAKUMAR, M.Sc., M.Phil., M.Tech.,
Assistant Professor of Computer Science &
Assistant Professor and Head, Department of M.Com.(CA),
Ayya Nadar Janaki Ammal College,
Sivakasi – 626 124.
Mobile: 099440-42243
e-mail : sivamsccsit@gmail.com
website: www.rdsivakumar.blogspot.in
REPRESENTATION OF SIGNED NUMBERS
2. If computers represent non-negative integers(unsigned) only.
Computers represent negative integers(signed) only.
The leftmost bit is 0, the number is positive.
The leftmost bit is 1, the number is negative.
REPRESENTATION OF SIGNED NUMBERS
Sign+magnitude representation
0100 = +4
1100 = -4
The left most bit indicate the sign “0” indicates the positive.
And “1” indicates the negative.
3. Change every 0 to 1 and every 1 to 0 .
Add 1 to the result.
Taken to pad(fill with zero) the original value out to the full representation width
before applying this algorithm.
8-bit representation to store the number.
2’s COMPLEMENT REPRESENTAION
.
The binary equivalent of 23 is 10111.
Pad with zeros to make 8-bit pattern 00010111.
Invert all the bits 11101000.
Add 1 to the result 11101001.
4. Manual method to represent signed integers
in 2’s complement form
This is an easier approach to represent signed integers.
This is for –ve numbers only.
Step 1: Copy the bits from right to left, through and including the first 1.
Step 2: Copy the inverse of the remaining bits.
Example 1:
To represent –4 in a 4-bit representation:
The binary equivalent of the integer 4 is 0100
As per step1, copy the bits from right to left, through and including the
first 1 => 100
As per step2, copy the inverse of the remaining bits => 1 100 => -4
Example 2:
To represent –23 in a 8-bit representation:
The binary equivalent of 23 is 00010111
As per step 1: 1
As per step 2: 11101001 => -23
5. Interpretation of unsigned and signed integers
X = 1001
Y = 0011
Comparing two binary number for finding which is greater, the comparison
Depends on whether the numbers are considered as signed or unsigned numbers.
(X>Y) is this true or false
If X is greater than Y because they are unsigned.
If X is less than Y because they are signed.
6. Range of unsigned and signed integers
.
In a 4-bit system, the range of unsigned integers is from 0 to 15, that is, 0000 to
1111 in binary form. Each bit can have one of two values 0 or 1. Therefore, the total
number of patterns of 4 bits will be 2 X 2 X 2 X 2 = 16. In an n-bit system, the total
number of patterns will be 2n.. Hence, if n bits are used to represent an unsigned
integer value, the range is from 0 to 2n-1, that is, there are 2n different values.
In case of a signed integer, the most significant (left most) bit is used to represent
a sign. Hence, half of the 2n patterns are used for positive values and the other half
for negative values. The range of positive values is from 0 to 2n-1-1 and the range
of negative values is from –1 to –2n-1. In a 4-bit system, the range of signed
integers is from –8 to +7.