---
# System prepended metadata

title: how computer stores negative n

---

how computer stores negative numbers (-11 as case study)
A modern computer invariably uses three methods in specific places.
A signed integer is stored in two’s complement. The most significant bit is taken to be negative and all the others positive. 
sign and magnitude form is a method of representing signed numbers in binary form. The most significant bit is only the sign bit. The rest of the bits are read just the same whether the number is positive or negative and the sign bit says which it is. So our -11 will be seen as 11110101 (8-bit two’s complement)
What are Complement and their types?
Complements are techniques used to represent negative numbers and simplify arithmetic operations (like subtraction) in computers. The two main types are:
1. One’s Complement :Obtained by flipping all bits of the number.
   - Example: -11 (11110101) → +11(00001011).
   
This two's complement representation is widely used in modern computer systems, including microprocessors, digital signal processors, and other digital hardware, to efficiently store and manipulate negative numbers.

In the past computers used other forms such as one’s complement (just invert the bits to negate a number) or sign and magnitude for integers, but modern computers have settled on the above formats. I don’t know of a single counter-example.
The various methods were chosen to make calculations efficient. Two’s complement allows us to do normal addition and subtraction using the same instructions on negative or positive numbers. 
Example: Solve -11 to 8 but binary using two complement
Solution:
Check for +11 in binary = 00001011
Then invert those Bits 
Original Bit
Inverted Bit
0     1
1     0

Original: 0 0 0 0 1 0 1 1
Inverted: 1 1 1 1 0 1 0 0

To invert bits manually, write down the original binary number, and just flip each digit to the opposite.
Therefore you’ll represent the answer by Adding 1
11110100
+       1
---------
11110101

✅ Final: 11110101 = This is -11 in two’s complement (8-bit)

Now we are to change to its Hexadecimal value (11110101) 
Solution:

we know binary is base-2 and hexadecimal is base-16. To convert binary 11110101 to hexadecimal First, convert 111101012 into decimal
11110101 base 2
1 × 271 × 261 × 251 × 240 × 231 × 220 × 211 × 20
= 245 base10
Now, we have to convert 245base10 to hexadecimal
245 / 16 = 15 with remainder 5
15 / 16 = 0 with remainder 15 (F) 

![photo_2025-06-13_07-21-56](https://hackmd.io/_uploads/rkAOSdYXxg.jpg)

Therefore our final answer is OxF5
