- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Sign Magnitude notation
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.
| +6|| 0110|
| -6|| 1110|
| +0|| 0000|
| -0|| 1000|
| +7|| 0111|
| -7|| 1111|
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.
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.
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.
There are two notations for 0(0000 and 1000), which is very inconvenient when the computer wants to test for a 0 result.
It is not convenient for the computer to perform arithmetic.
Hence, due to the above mention ambiguities, SM notation is generally not used to represent signed numbers inside a computer.
- The magnitude of big data
- Big Oh Notation (O)
- Little Oh Notation (o)
- What is Postfix Notation?
- How to plot magnitude spectrum in Matplotlib in Python?
- 1's complement notation
- 2's complement notation
- Prevent scientific notation in matplotlib.pyplot
- Cascade notation in Dart Programming
- How to plot longitudinal magnitude spectrum in Matplotlib using Python?
- Evaluate Reverse Polish Notation in C++
- Java program to display Astrological sign or Zodiac sign for given date of birth
- Python program to display Astrological sign or Zodiac sign for a given data of birth.