Different ways to represent Signed Integer
Last Updated :
07 Apr, 2025
A signed integer is an integer with a positive ‘+’ or negative sign ‘-‘ associated with it. Since the computer only understands binary, it is necessary to represent these signed integers in binary form.
In binary, signed Integer can be represented in three ways:
- Signed bit.
- 1’s Complement.
- 2’s Complement.
Let us see why 2’s complement is considered to be the best method.
Signed bit Representation
In the signed integer representation method the following rules are followed:
1. The MSB (Most Significant Bit) represents the sign of the Integer.
2. Magnitude is represented by other bits other than MSB i.e. (n-1) bits where n is the no. of bits.
3. If the number is positive, MSB is 0 else 1.
4. The range of signed integer representation of an n-bit number is given as –2n-1 – 1 to 2n-1 – 1.
Example:
Let n = 4
Range:
–(24-1 – 1) to 24-1 – 1
= -(23– 1) to 23 – 1
= -(7) to +7
For 4 bit representation, minimum value=-7 and maximum value=+7
Positive Numbers
|
Sign |
Magnitude |
Decimal Representation |
0 |
0 |
0 |
0 |
+0 |
0 |
0 |
0 |
1 |
+1 |
0 |
0 |
1 |
0 |
+2 |
0 |
0 |
1 |
1 |
+3 |
0 |
1 |
0 |
0 |
+4 |
0 |
1 |
0 |
1 |
+5 |
0 |
1 |
1 |
0 |
+6 |
0 |
1 |
1 |
1 |
+7 |
Negative Numbers
|
Sign |
Magnitude |
Decimal Representation |
1 |
0 |
0 |
0 |
-0 |
1 |
0 |
0 |
1 |
-1 |
1 |
0 |
1 |
0 |
-2 |
1 |
0 |
1 |
1 |
-3 |
1 |
1 |
0 |
0 |
-4 |
1 |
1 |
0 |
1 |
-5 |
1 |
1 |
1 |
0 |
-6 |
1 |
1 |
1 |
1 |
-7 |
Drawbacks:
1. For 0, there are two representations: -0 and +0 which should not be the case as 0 is neither –ve nor +ve.
2. Out of 2n bits for representation, we are able to utilize only 2n-1 bits.
3. Numbers are not in cyclic order i.e. After the largest number (in this, for example, +7) the next number is not the least number (in this, for example, +0).
4. For negative numbers signed extension does not work.
Example:
Signed extension for +5

Signed extension for -5

5. As we can see above, for +ve representation, if 4 bits are extended to 5 bits there is a need to just append 0 in MSB.
6. But if the same is done in –ve representation we won’t get the same number. i.e. 10101 ≠11101.
1’s Complement representation of a signed integer
In 1’s complement representation the following rules are used:
1. For +ve numbers the representation rules are the same as signed integer representation.
2. For –ve numbers, we can follow any one of the two approaches:
- Write the +ve number in binary and take 1’s complement of it.
1’s complement of 0 = 1 and 1’s complement of 1 = 0
Example:
(-5) in 1’s complement:
+5 = 0101
-5 = 1010
- Write Unsigned representation of 2n – 1 – X for –X. Here n represent n-bit system.
Example:
X = -5
for n=4
24-1-5=10
10 in Binary System is written as: 1010(Unsigned)
3. The range of 1’s complement integer representation of n-bit number is given as –(2n-1 – 1) to 2n-1 – 1.
1’s Complement Representation:
Positive Numbers |
Sign |
Magnitude |
Number |
0 |
0 0 0 |
+0 |
0 |
0 0 1 |
+1 |
0 |
0 1 0 |
+2 |
0 |
0 1 1 |
+3 |
0 |
1 0 0 |
+4 |
0 |
1 0 1 |
+5 |
0 |
1 1 0 |
+6 |
0 |
1 1 1 |
+7 |
Negative Numbers |
Sign |
Magnitude |
Number |
1 |
0 0 0 |
-7 |
1 |
0 0 1 |
-6 |
1 |
0 1 0 |
-5 |
1 |
0 1 1 |
-4 |
1 |
1 0 0 |
-3 |
1 |
1 0 1 |
-2 |
1 |
1 1 0 |
-1 |
1 |
1 1 1 |
-0 |
Drawbacks:
- For 0, there are two representations: -0 and +0 which should not be the case as 0 is neither –ve nor +ve.
- Out of 2n bits for representation, we are able to utilize only 2n-1 bits.
Merits over Signed bit representation:
1. Numbers are in cyclic order i.e. after the largest number (in this, for example, +7) the next number is the least number (in this, for example, -7).
2. For negative number signed extension works.
Example: Signed extension for +5

Signed extension for -5

3. As it can be seen above, for +ve as well as -ve representation, if 4 bits are extended to 5 bits there is a need to just append 0/1 respectively in MSB.
2’s Complement representation
In 2’s Complement representation the following rules are used:
1. For +ve numbers, the representation rules are the same as signed integer representation.
2. For –ve numbers, there are two different ways we can represent the number.
- Write an unsigned representation of 2n – X for –X in n-bit representation.
Example:
(-5) in 4-bit representation
24 – 5 = 11 -→1011(unsigned)
- Write a representation of +X and take 2’s Complement.
To take 2’s complement simply take 1’s complement and add 1 to it.
Example:
(-5) in 2’s complement
(+5) = 0101
1’s complement of (+5) = 1010
Add 1 in 1010: 1010+1 = 1011
Therefore (-5) = 1011
3. Range of representation of n-bit is –2n-1 to 2n-1 – 1.
2’s Complement representation (4 bits)

Merits:
- No ambiguity in the representation of 0.
- Numbers are in cyclic order i.e. after +7 comes -8.
- Signed Extension works.
- The range of numbers that can be represented using 2’s complement is very high.
Due to all of the above merits of 2’s complement representation of a signed integer, binary numbers are represented using 2’s complement method instead of signed bit and 1’s complement.
What is 9s complement?
The 9’s complement of a decimal number is found by subtracting each digit of the number from 9.
What is 7’s complement?
7’s complement of a number is obtained by subtracting all bits from 777.
How to calculate n’s compliment ?
by subtracting the all bits of the number from n-1 .
Similar Reads
Detect if two integers have opposite signs
Given two integers a and b, the task is to determine whether they have opposite signs. Return true if the signs of the two numbers are different and false otherwise. Examples: Input: a = -5, b = 10Output: trueExplanation: One number is negative and the other is positive, so their signs are different
9 min read
Unsigned and Signed Numbers Representation in Binary Number System
The binary number system uses only two digits, 0 and 1, to represent all data in computing and digital electronics. Understanding unsigned and signed numbers is important for efficient data handling and accurate computations in these fields. The binary system forms the foundation of all digital syst
6 min read
String to Integer - Write your own atoi()
Given a string s, the task is to convert it into integer format without utilizing any built-in functions. Refer the below steps to know about atoi() function. Examples: Input: s = "-123"Output: -123 Input: s = " -"Output: 0Explanation: No digits are present, therefore 0. Input: s = " 123123123131113
7 min read
Division Algorithm in Signed Magnitude Representation
The Division of two fixed-point binary numbers in the signed-magnitude representation is done by the cycle of successive compare, shift, and subtract operations. The binary division is easier than the decimal division because the quotient digit is either 0 or 1. Also, there is no need to estimate ho
3 min read
Swift - Integer, Floating-Point Numbers
Integers are whole numbers that can be negative, zero, or positive and cannot have a fractional component. In programming, zero and positive integers are termed as âunsignedâ, and the negative ones are âsignedâ. Swift provides these two categories in the form of 8-bit, 16-bit, 32-bit and 64-bit form
2 min read
Convert a number into negative base representation
A number n and a negative base negBase is given to us, we need to represent n in that negative base. Negative base works similar to positive base. For example in base 2 we multiply bits to 1, 2, 4, 8 and so on to get actual number in decimal. In case of base -2 we need to multiply bits with 1, -2, 4
6 min read
Binary Representations in Digital Logic
Binary representation is the method of expressing numbers using binary digits (bits). In digital logic, binary representations are important as they are the foundation for all computations and data processing in computers. Binary numbers form the backbone of digital circuits and systems.Each binary
12 min read
Floating Point Representation - Basics
Floating-point representation helps computers handle real numbers with a large range of values, both very small and very large. The single precision format uses 32 bits, while double precision uses 64 bits, allowing for more precision and a larger range. These formats are based on scientific notatio
9 min read
Representation of Negative Binary Numbers
In computer systems, binary numbers use only two symbols: 0 and 1. Unlike decimal numbers, binary numbers cannot include a plus (+) or minus (-) symbol directly to denote positive or negative values. Instead, negative binary numbers are represented using specific methods that incorporate a special b
3 min read
JavaScript Number isSafeInteger() Method
What is a Safe Integer? A safe integer is an integer that has the following properties A number that can be represented as an IEEE-754 double precision number i.e. all integers from (253 - 1) to -(253 - 1)).What is an IEEE-754 double-precision number? Double-precision floating-point format is a comp
2 min read