signed Vs unsigned

Signed and Unsigned are two words are Antonyms to each other, that means if we understand signed then unsigned is opposite to it.

What does sign means?

Let us first understand what does sign means in English. In simple term’s it means a signal, indication, mark or a way to represent things and according to dictionary meaning sign means:
Noun sign has 11 senses:
  1. a perceptible indication of something not immediately apparent (as a visible clue that something has happened);
  2. a public display of a (usually written) message;
  3. any communication that encodes a message;
  4. structure displaying a board on which advertisements can be posted;
  5. one of 12 equal areas into which the zodiac is divided;
  6. any objective evidence of the presence of a disorder or disease (medicine);
  7. having an indicated pole (as the distinction between positive and negative electric charges);
  8. an event that is experienced as indicating important things to come;
  9. a gesture that is part of a sign language;
  10. a fundamental linguistic unit linking a signifies to that which is signified;
  11. a character indicating a relation between quantities;
Verb sign has 8 senses:
  1. mark with one’s signature; write one’s name (on);
  2. approve and express assent, responsibility, or obligation
  3. be engaged by a written agreement;
  4. engage by written agreement;
  5. communicate silently and non-verbally by signals or signs;
  6. place signs, as along a road; “sign an intersection”;
  7. communicate in sign language;
  8. make the sign of the cross over someone in order to call on God for protection;
Adj. sign has 1 sense (no senses from tagged texts)
  1. used of the language of the deaf

What does sign means in computer’s?

A computer is a programmable machine designed to sequentially and automatically carry out a sequence of arithmetic or logical operations. It means that computer deals with math’s and thus we have to now understand what does sign means in math’s.
In mathematics, the word sign refers to the property of being positive or negative. Every non-zero real number is either positive or negative, and therefore has a sign. Zero itself is signless, although in some contexts it makes sense to consider a signed zero. In addition to its application to real numbers, the word sign is used throughout mathematics to indicate aspects of mathematical objects that resemble positivity and negativity, such as the sign of a permutation. The word sign is also sometimes used to refer to various mathematical symbols, such as the plus and minus symbols and the multiplication symbol.
In computer all the information is stored as bytes and it is the basic addressable element in many computer architecture. A unit of memory or data equal to the amount used to represent one character; on modern architectures this is invariably 8 bits.  However, a computer can only store information in bits, which can only have the values zero or one. We might expect, therefore, that the storage of negative integers in a computer might require some special method. Thus, we can say this method is the sign or indication to do something special or follow the certain method to do negative calculations.
The calculations of negative values are treated as special case in programming and thus have the special sign to do negative calculations or storage. Thus, if the special sign is not provided all values are treated as unsigned. But in reality the default type is taken as singed in programming languages. In Language C, the keyword signed or unsigned are used to represent the singed or unsigned representation for calculations of negative or positive values.
Conclusion:- Unsigned is either positive or zero and Signed can be positive or negative.

How negative number’s are stored in computer or How signed number’s are stored?

Since, the computer only understand true or false i.e. values 0 or 1. Thus, it make’s more interesting to now how the negative number’s are store. Since, as discussed 0 and 1 both are positive and thus we are discussing here how it is done. Thus, in computing, signed number representations are required to encode negative numbers in binary number systems. Before, we start different methods we have know some terms and which are 8 bit representation
8 bit representation
7 6 5 4 3 2 1 0

Most significant bit

In computing, the most significant bit (msb, also called the high-order bit) is the bit position in a binary number having the greatest value. The msb is sometimes referred to as the left-most bit due to the convention in positional notation of writing more significant digits further to the left. In the below example yellow portion is MSB.
8 bit – MSB representation
7 6 5 4 3 2 1 0

Least significant bit

In computing, the lease significant bit (lsb, also called the right-most-bit) is the bit position in a binary number having the lowest value. The lsb is sometimes referred to as the right-most bit due to the convention in positional notation of writing more significant digits further to the right. It is analogous to the least significant digit of a decimal integer, which is the digit in the ones (right-most) position. In the below example yellow portion is LSB.
8 bit – LSB representation
7 6 5 4 3 2 1 0
The four best-known methods of extending the binary numeral system to represent signed numbers are:

1. sign-and-magnitude

The sign-and-magnitude binary format is the simplest conceptual format. Binary numbers do not provide the option of the symbols “+” and “-” but require that binary bits have values of either 0 or 1.

Method of sign-and magnitude

  1. MSB, bit is devoted to sign
  2. usually 1 => negative and 0 => positive
  3. 0 to 6 bits are available to represent magnitude
8 bit – sign-magnitude representation of 37
0 0 1 0 0 1 0 1
8 bit – sign-magnitude representation of -37
1 0 1 0 0 1 0 1

Problems with Sign-Magnitude

  1. One pattern corresponds to “minus zero”, 1000 0000. Another corresponds to “plus zero”, 0000 0000.
  2. It works well for representing positive and negative integers (although the two zeros are bothersome). But it does not work well in computation. A good representation method (for integers or for anything) must not only be able to represent the objects of interest, but must also support operations on those objects.

2. ones’ complement

Positive integers are represented in the same way as sign-magnitude notation. However, negative numbers are represented differently. Representing a signed number with 1’s complement is done by changing all the bits that are 1 to 0 and all the bits that are 0 to 1. The ones’ complement of the number then behaves like the negative of the original number in most arithmetic operations. Ones’ complement historically important as the early computers were based on One complement but now, nobody builds machines.

Method of ones’ complement

  1. MSB, bit is devoted to sign
  2. usually 1 => negative and 0 => positive
  3. Changing all the bits that are 1 to 0 and all the bits that are 0 to 1.
8 bit – sign-magnitude representation of 47
0 0 1 0 1 1 1 1
8 bit – sign-magnitude representation of -47
1 1 0 1 0 0 0 0

Problems with Sign-Magnitude

  1. An unfortunate feature of One’s Complement representation is that there are two ways of representing the value zero: all bits set to zero (00000000), and all bits set to one(11111111).
  2. More importantly, when performing arithmetic operations, we need to treat negative operands as special cases.
  3. We have to perform an extra task to get the correct answer i.e. in Adding two number’s the adding of 1.

3. Excess-K

Excess K is also known as Offset Binary representation. The end result of using the digital systems is the conversion of analog signals to digital format. Offset binary is commonly used in image processing to display negative pixels values. It is not possible to display negative intensities, so offsetting zero to mid-grey shows negative values as darker and positive values as lighter. Offset binary is also often used in Digital Signal Processing (DSP). Most analog to digital (A/D) and digital to analog (D/A) chips are unipolar, which means that they cannot handle bipolar signals (signals with both positive and negative values). A simple solution to this is to bias the analog signals with a DC offset equal to half of the A/D and D/A converter’s range. There is no standard for offset binary but in a digital coding scheme in which the most negative value is represented by all zeros (00000000) and the most positive value is represented by all ones (11111111).
One logical way to represent signed integers is to have enough range in binary numbers so that the zero can be offset to the middle of the range of positive binary numbers. Then the magnitude of a negative binary number can be simply subtracted from that zero point.
Most standard computer CPU chips cannot handle the offset binary format directly. CPU chips typically can only handle signed and unsigned integers, and floating point value formats. Offset binary values can be handled in several ways by these CPU chips. The data may just be treated as unsigned integers, requiring the programmer to deal with the zero offset in software. The data may also be converted to signed integer format (which the CPU can handle nativity) by simply subtracting the zero offset. Notice that as a consequence of the fact that the commonest offset for an n-bit word is 2n-1, which implies that the first bit is inverted relative to twos’ complement, one need not have a separate subtraction step, but simply can invert the first bit. This sometimes is a useful simplification in hardware, and can be convenient in software as well.

Method of Excess-K

  1. MSB, bit is devoted to sign
  2. usually 1 => negative and 0 => positive
  3. Calculate the biased Number n-bit word is 2n-1
  4. subtracting biased Number to all number to representation
3 bit representation
pattern unsigned signed
000 0 -4
001 1 -3
010 2 -2
011 3 -1
100 4 0
101 5 1
110 6 2
111 7 3
Notice that we still preserve the concept of a “sign bit” – it just happens to be inverted from our prior representation. If we prepare the addition table for this representation, we get:
Unsigned Addition Table (same table as before)
+ 000 (0) 001 (1) 010 (2) 011 (3) 100 (4) 101 (5) 110 (6) 111 (7)
000 (0) 000 001 010 011 100 101 110 111
001 (1) 001 010 011 100 101 110 111 [000]
010 (2) 010 011 100 101 110 111 [000] [001]
011 (3) 011 100 101 110 111 [000] [001] [010]
100 (4) 100 101 110 111 [000] [001] [010] [011]
101 (5) 101 110 111 [000] [001] [010] [011] [100]
110 (6) 110 111 [000] [001] [010] [011] [100] [101]
111 (7) 111 [000] [001] [010] [011] [100] [101] [110]
Signed Addition Table (using offset binary representation of  negative numbers)
+ 000 (-4) 001 (-3) 010 (-2) 011 (-1) 100 (0) 101 (1) 110 (2) 111 (3)
000 (-4) [100] [101] [110] [111] 000 001 010 011
001 (-3) [101] [110] [111] 000 001 010 011 100
010 (-2) [110] [111] 000 001 010 011 100 101
011 (-1) [111] 000 001 010 011 100 101 110
100 (0) 000 001 010 011 100 101 110 111
101 (1) 001 010 011 100 101 110 111 [000]
110 (2) 010 011 100 101 110 111 [000] [001]
111 (3) 011 100 101 110 111 [000] [001] [010]

Problems with Excess-K

  1. The principal drawback of offset binary is that, for numbers that exist in both the signed and the unsigned representations, the representations are different. It would be convenient if this were not the case.

4. Two’s complement

A two’s complement system, or two’s complement arithmetic, is a system in which negative numbers are represented by the two’s complement of the absolute value; this system is the most common method of representing signed integers on computers.
There are a number of nice features to two’s complement representation. The first is that the normal rules used in the addition of (unsigned) binary integers still work (throw away any bit carried out of the left-most position). Second, it’s easy to negate any integers: simply complement each bit and add 1 to the result (011101 complemented is 100010 plus 1 is 100011; 100011 complemented is 011100 plus 1 is 011101). Finally, the MSB tells you if the integer is positive (0) or negative (1).
The two’s complement system has the advantage of not requiring that the addition and subtraction circuitry examine the signs of the operands to determine whether to add or subtract. This property makes the system both simpler to implement and capable of easily handling higher precision arithmetic. Also, zero has only a single representation, obviating the subtleties associated with negative zero, which exists in ones complement systems.
In two’s complement, positive numbers are represented as binary numbers whose MSB is 0. Negative numbers are represented with the MSB is 1, making use of the left-most bit’s negative weight. All radix complement number systems use a fixed-width encoding. Every number encoded in such a system has a fixed width so the most-significant digit can be examined. Positive two’s complement integers have the same representation as unsigned numbers. The range of values for an (n+1) bit two’s complement integer is 2n to 2n – 1.
Two’s Complement encoding basically takes the Offset Binary input and inverts the MSB. 2’s Complement coding is desired in those applications where a lot is math is performed on the ADC output word. ADC’s with 2’s Complement output generally have differential inputs.

Method of Two’s Complement

  1. MSB, bit is devoted to sign
  2. usually 1 => negative and 0 => positive
  3. a positive number is represented by its ordinary binary representation, using enough bits that the high bit (the sign bit) is 0. The two’s complement operation is the negation operation, so negative numbers are represented by the two’s complement of the representation of the absolute value.
  4. To find the two’s complement of a binary number, the bits are inverted, or “flipped”, by using the bitwise NOT operation; the value of 1 is then added to the resulting value. Bit overflow is ignored, which is the normal case with the zero value.
Tagged , , ,

One thought on “signed Vs unsigned

  1. Efrain Meuse says:

    Nice post. I was checking constantly this weblog and I am impressed! Very helpful info specifically the last phase 🙂 I take care of such information a lot. I used to be looking for this certain information for a long time. Thank you and good luck.

Comments are closed.

%d bloggers like this: