# A Question About Base 3 Subtruction

• transgalactic

#### transgalactic

i can't understand how it works:
i have two bit numbers (x1 x0 ,y1 y0) which are needed to be subtructed

i can't understand why
x1 x0 y1 y0 | B D1 D2
0 0 0 1 | 1 1 0
0 0 1 0 | 1 0 1
0 0 1 1 | X X X

i can't understand these arithmetics
the first one is 0-1=-1
so in base 3 the resolt is should be three but i can't understand what meen Borrow=1
and the resolt 10
i don't understand how did they desided that

and why we have don't cares on the third example

i can't understand how it works:
i have two bit numbers (x1 x0 ,y1 y0) which are needed to be subtructed

i can't understand why
x1 x0 y1 y0 | B D1 D2
0 0 0 1 | 1 1 0
0 0 1 0 | 1 0 1
0 0 1 1 | X X X

i can't understand these arithmetics
the first one is 0-1=-1
so in base 3 the resolt is should be three but i can't understand what meen Borrow=1
and the resolt 10
i don't understand how did they desided that

and why we have don't cares on the third example
Base 3? It looks to me like you are working in base 2!

However, even in base 3, the "result" of a calculation is never "3". It might be 103 (where the 3 indicates the number is written in base 3) but the only digits ("trigits"?) in base 3 are 0, 1, and 2.

Oh, wait, I see. You are doing base 2, binary, arithmetic, but assuming that you can only keep 3 bits, the first being the "sign bit". What you are you are doing is is binary arithmetic (base 2) with the computer notation "two's complement" for negative numbers. Looks like a very simple example of what happens in a computer with 16 bits per number.

Specifically, 0- 1= -1 whether you are in decimal or binary. In "twos complement" negative numbers are represented by having the first bit 1 (positive numbers always have the first bit 0. It's called the "sign bit".) and the rest of the bits the complement of the corresponding positive number. The number "1" would be 001 in this form so "-1" is : first the "sign bit" becomes 1, the the complement of 01 is 10, so -1 is represented by 110.

For the second problem, 0- 10= -10 so the "sign bit" becomes 1 and the complement of 10 is 01: -2 is represented by 101.

For the third, 0- 11= -11 so the "sign bit" becomes 1 and the complement of 11 is 00. The result is 100.

The advantage of "twos complement" is that you don't have to "borrow". But if you want to use "borrowing", its exactly what you learned in elementary school. To subtract 14 from 31 you think "since 4 is larger than 1, I have to borrow 10 from the 10s place. Of course, the "3" in the 10s place really represents 30. Borrowing 10 from the 10s place leave 20- so "2" in the 10s place- and gives 11 in the units place. 11- 4= 7 so you have 7 in the units place. 2- 1= 1 so you have 1 in the 10s place: 31- 14= 17.

It's exactly the same in binary.