# Sign Magnitude notation

MicrocontrollerMicroprocessor8085Computers

#### Choose the Right Microcontroller

20 Lectures 1 hours

#### Microcontroller Interfacing with Different Elements

16 Lectures 1.5 hours

22 Lectures 1.5 hours

The sign-magnitude binary format is the simplest conceptual format. In this method of representing signed numbers, the most significant digit (MSD) takes on extra meaning.

• If the MSD is a 0, we can evaluate the number just as we would any normal unsigned integer. And also we shall treat the number as a positive one.

• If the MSD is a 1, this indicates that the number is negative.

The other bits indicate the magnitude (absolute value) of the number. Some of the signed decimal numbers and their equivalent in SM notation follows assuming a word size of 4 bits.

Signed decimal
sign-magnitude
+6
0110
-6
1110
+0
0000
-0
1000
+7
0111
-7
1111

## Range

From the above table, it is obvious that if the word size is n bits, the range of numbers that can be represented is from -(2n-1 -1) to +(2n-1 -1). A table of word size and the range of SM numbers that can be represented as shown in the following.

Word size
The range for SM numbers
4
-7 to +7
8
-127 to +127
16
-32767 to +32767
32
-2147483647 to +2147483647

Notice that the bit sequence 1101corresponds to the unsigned number 13, as well as the number –5 in SM notation. Its value depends only on the way the user or the programmer interprets the bit sequence.

A number is represented inside a computer with the purpose of performing some calculations using that number. The most basic arithmetic operation in a computer is the addition operation. That’s why a computer can also be called as an adder.

When adding two numbers with the same signs, add the values and keep the common sign.

## Example 1

Add the numbers (+5) and (+3) using a computer. The numbers are assumed to be represented using 4-bit SM notation.

             111  <- carry generated during addition
0101 <- (+5) First Number
+ 0011 <- (+3) Second Number
1000 <- (+8) Sum                 

Let’s take another example of two numbers with unlike signs.

## Example  2

Add the numbers (-4) and (+2) using a computer. The numbers are assumed to be represented using 4-bit SM notation.

              000 <- carry generated during addition              1100 <- (-4) First number           +  0010 <-(+2) Second Number              1110 <- (-2) Sum

Here, the computer has given the wrong answer of -6 = 1110, instead of giving the correct answer of -2 = 1010.