^ Alright! I'll add some text for calculation negative numbers (as soon as i figure out how to do that).

So for binary numbers, value = (non sign bits' sum) - sign bit?

The most significant bit counts for negative what it used to, yes. So if it was an 8 bit number then the most significant bit would be -128 instead of 128, and the rest of the bits would stay the same.

The easiest way to negate a number that I know of is to flip all the bits then add one (effectively flipping all the bits after the first one from right to left):

34 = 00100010

-> 11011101

+ 00000001

= 11011110

= -128 + 64 + 16 + 8 + 4 + 2 = -34

So for binary numbers, value = (non sign bits' sum) - sign bit?]]>

▼Quick rundown on calculating two's complement values

For example, take the calculation 10 + (-3). Normally you could represent 10 in 4 bits, but since we need the MSB to be a sign bit we have to use at least 5.

```
01010 (10)
+ 11101 (-3)
-----------------
00111 ( 7)
```

Technically this does overflow (the output value is 100111 = -25, but since we're using 5-bit hardware in this example we have to throw out the MSB). At this moment I don't remember the rules for when overflow should be ignored.

]]>In this section we will use 5+7 as an example. 5 = 101 and 7 = 111. Add them up together in binary and you'll get 1100(12). Let's take a look at how the binary calculator is going to accomplish that. So first of all, you need to let your calculator know that 1+1=10,1+0=1,0+1=1,and0+0=0. You need to do that for every bit. 1+1 is fairly tricky compared to the others. Because it advances a bit. You'll need to check that digit to see if it equals 1. If yes, change that to 0 an

▼View

**Binary Subtraction**

this section we will use 9-3 as an example. 9 = 1001, 6 = 110, 9-6 = 11This is a bit trickier than the addition, but is simpler than multiplication and division. First, know that 1-1 = 0, 1-0 = 0, 0-1 = -1, 0-0 = 0. Subtract each bit and you'll get 10(-1)0. Since -1 is not a part of binary bits, We'll have to get rid of it. From the -1, check the left number. If it is 1, change it to 0 and the bit itself to 1. If it is -1, then continue looking left, when 1 is found, drop down the chain of -1s until your original bit. If it is 0, or if your chain of -1s has 0s in it, continue searching. When a 1 is found, change it to 1 if there are -1s after it(It gives 1 to the -1), If there aren't -1s after it, don't do anything. Alright let's test! Step 1: Subtract bits 1001 - 110 = 1(-1)(-1)1. Step 2: Clearing -1s: rightmost -1: the left is a -1, So it has to be 1. Leftmost -1: The right is a -1, the left is a 1. Take the 1 and give it to the right -1. Step 3: Answer! 1001 - 110 = 11!

P.S.: I forgot to take screenshots...