---
# System prepended metadata

title: Untitled

---

# How Computers Store Negative Numbers (Using -11 as a Case Study) 


The truth is that most computer users are not interested in what happens when they in put data into the computer system using in put deviuces like keyboard, microphones etc. They just want to see a result and that is all. But here is even the better truth, they do not need to know what happens behind the hood. 
The question is this, `can this be the same case for a software engineer ?`
Let us use a simple case scenario, a negative sign is simply placed in front of numbers like -5 or -11 when writing them on paper.  The only binary that computers can comprehend is 1s and 0s; they are unable to comprehend minus signs.  What is their approach to handling negative numbers?  Various approaches to number representation are useful in this situation.  With time, computer scientists found effective methods for binary storage of both positive and negative values.  The three most popular approaches are One's Complement, Two's Complement, and Sign and Magnitude.

    1. Sign and Magnitude

Sign and Magnitude is one of the simplest methods to represent negative numbers in binary. It divides the binary number into two parts. The leftmost bit, known as the sign bit, indicates whether the number is positive or negative: 0 for positive and 1 for negative. The other bits show the size of the number, just like regular binary.
For instance, to store the number +11 in 8 bits, we start with the binary for 11, which is `00001011`. Since it’s positive, the sign bit stays 0. For -11, we change the sign bit to 1, resulting in `10001011`. That’s all there is to it. However, this method has a significant issue; it creates two types of zero: `00000000` (positive zero) and `10000000` (negative zero). While this may seem minor, it becomes a serious problem in computing, where precision and consistency are crucial. Because of this, Sign and Magnitude is infrequently used in modern systems.

`2. One’s Complement`
One’s Complement builds on Sign and Magnitude by removing the need to mark the sign separately. Instead, it flips all the bits in the number to represent a negative value. Each 0 becomes 1, and each 1 becomes 0. This process is known as bitwise inversion, which is why this method is called “One’s Complement.”
Let’s consider the number +11 again. Its binary form in 8 bits is `00001011`. To get -11 using One’s Complement, we invert each bit:
`00001011 → 11110100`
This final binary number, `11110100`, now represents -11.
The main benefit here is that we no longer need a separate sign bit; the entire binary number indicates negativity. However, there is still a problem: One’s Complement also results in two kinds of zero, `00000000 `and 1`1111111`. This double-zero issue can disrupt calculations. For this reason, One’s Complement was eventually replaced with a better method.

`3. Two’s Complement (The Standard)`
Two’s Complement is the method that most modern computers use to store negative numbers. It completely resolves the double-zero problem and simplifies binary subtraction for processors. It operates similarly to One’s Complement but includes an extra step: after flipping the bits, you add 1. This small addition has a significant effect.
To convert -11 into binary using Two’s Complement, we follow three simple steps:

`Step-by-Step: Converting -11 to Two’s Complement (8 bits)`
Step 1: Write the binary of +11
In 8-bit form:
`00001011`
Step 2: Flip all the bits
Invert each bit (0 becomes 1, 1 becomes 0):
`11110100`
Step 3: Add 1 to the result
`11110100 + 1 = 11110101`
The 8-bit Two’s Complement representation of -11:
`11110101`
This binary number now perfectly represents -11 in a way that the computer can use for calculations. Importantly, there is only one type of zero in Two’s Complement `(00000000)`, which prevents confusion caused by the earlier methods.Converting to Hexadecimal

Let’s now convert our 8-bit binary (11110101into hexadecimal, which is another way computers store and display numbers.

Step 1: Break it into 4-bit chunks
`1111 0101`
```
1x2 <sup>3</sup>1x2 <sup>2</sup>1x2 <sup></sup>1x2 <sup>1</sup>
```

Step 2: Convert each part to hex

`1111 = F`
`0101 = 5`
Final hexadecimal value of -11:
`0xF5`

`Here is what I learned`
Before writing this article, I thought storing negative numbers in a computer was simply about adding a minus sign. I never realized there were different methods, each with its own rules, strengths, and weaknesses. Learning about Sign and Magnitude, one’s complement, and especially two’s complement showed me how deep and technical even small aspects of computing can be.

My biggest challenge was understanding why some methods are no longer used. At first, they all seemed correct, but I needed some research to see how issues like “two versions of zero” could cause problems inside a computer. I also found it hard to follow the steps for flipping bits and adding 1. However, once I tried this with -11, it finally made sense.

What I’ve learned is that computing isn’t just about writing code or solving big problems. It’s about truly understanding how the smallest components work behind the scenes. Now, every time I see a negative number in a program or a system, I will know exactly what is happening under the hood.

