11/23/11

Moved: Trinary numbers and math

This was posted a few years ago on my previous blog (which I abandoned). I updated it slightly:

In my last post I explained how Trinary logic can be used in place of binary logic, now I am going to show you how multidigit Trinary numbers work and how to add, subtract, multiply and divide them.

Trinary numerals greater than 1 or less than - work much like normal numbers. You take place value (1, 3, 9, 27, 81, 243, etc.) and multiply it by the digit value. The diference in trinary is that digit values can be negative. For instance:

1-01 = 27 - 9 + 0 + 1 = 19

In this way, counting in Trinary goes like this:

0, 1,
1-, 10, 11,
1--, 1-0, 1-1, 10-, 100, 101, 11-, 110, 111

and so on.


NOTE: Here I transition from counting to math, and it gets confusing. You might want to write out the trinary numbers and perform the math as I explain it.



Addition in Trinary

Say we are adding 123 and 21.
In Trinary these are 1----0 and 1-10
We add right  to left. Column 1 is 0 + 0 which equals 0. Column 2 is - + 1 which equals 0.

Colunm 3 is is - + -. Here is where we get to the weird part. In trinary addition, we can end up with "borrowing" as we would in normal subtraction. We put a 1 at the bottom of column 3 and a - at the top of column 4. Column 4 now has two -'s and one 1, so it equals -. For the next two columns we just bring down the value from the top row because the bottom row is empty. Our final answer is 1--100, which is 243 - 81 - 27 + 9 = 144. Carrying out the same calculation in base 10, we discover that 123 + 21 = 144.


Subtraction in Trinary

The easiest way is to negate the second number and add them. In Trinary, negation is easy. The opposite of 1 is - and vice versa, so to negate a number we simple change every 1 into - and vice versa.

Say we are doing 154 - 62
154 is 1-0-01
62 is 1-10-
-62 is -1-01
So we are performing 1-0-01 + -1-01

Column 1 is 1 + 1, so we write - in the bottom of column 1 and 1 in the top of column 2. As it turns out, the other numbers in column 2 are all 0's so we write 1 in the bottom of it as well. Column 3 is - + -, so we put 1 in the bottom of column 3 and - in the top of column 4. Column 4 is - + 0 + 1, so put 0 in the bottom of column 4.
Column 5 is - + -, so we put one in the bottom of column 5 and - in the top of column 6. Column 6 is now - + 1, so we leave it blank.

Our answer is 1011-, or 81 + 9 + 3 - 1, or 92. Performing 154 - 62 in base 10, we discover that it also is 92.


 Multiplication in Trinary is like repeated addition and subtraction.

I will start with a simple square, 8 * 8.
8 is 10-

We start from the bottom right. - times 10- is -01 Since this is in the first bottom digit we do not shift it. 0 times 10- is nothing. 1 times 10- is 10-, but since it is in the third digit, we need to shift it two digits to the left to get 10-00.
We add 10-00 and -01 to get the answer.
Coumn 1 is 1. Column 3 is - + -, or 1 with a - in column 4. We bring down the - in column 4 because column 4 is empty. Column 5 is 1.

Our answer is 1-101, or 81 - 27 + 9 + 1, or 64.


Division is repeated addition and subtraction as well.

Say we are performing 60/10.
60 is 1-1-0
10 is 101

This should come out evenly in Trinary because we know it does in base 10.

The division question in Trinary is "Can +or- B be subtracted from this part of A?" instead of "Is B less than this part of A?".






 In division we work from left to right. So, first we look at the first 3 digits, 1-1. Positive 101 can be subtracted from 1-1 to make -0, so our answers 3rd (3rd from the right) digit is 1. Now we have -0-. Negative 101 can be subtracted from -0- to make 0. Our 2nd digit is -. We are left with 000, so out 1st digit is 0. Our answer is 1-0, or 9 - 3, or 6.

No comments:

Post a Comment