Arch Linux. Not as scary as you think.

Image
Yes I'm a nerd. Yes I use Arch Linux. There is a somewhat unfair view that you have to be a programmer to use Linux, and that Arch Linux in particular is very difficult. Yes I happen to be a programmer, and it might be true that Linux may be particularly useful for programmers considering most distros come with a lot of editors and compilers and such. But it really is a really stable and powerful OS for anyone (that's not computer illiterate). If you want to just use your computer without having to thinking about it, you will probably use whatever Windows version your computer came shipped with, and not bother to install anything else. However if you actually want to Learn how to use Linux, Arch is a good choice, because it assumes you know how to use the command line during the install process. In other words the process of installing it forces you learn som basics of Linux (if you don't already know). Still it is not very difficult. You don't have to compile

Binary Arithmetics


This is a continuation of my last post about Binary Numerals.
When we know what binary is, we of course want to be able to apply maths to it.

Binary Addition

Line the two numbers up, one over the other and start adding each column, starting from the right.
There are four possible results:
0 + 0 = 0
1 + 0 = 1
0 + 1 = 1
1 + 1 = 0 (carry 1)

In the fourth case the result is 10, so 0 is written and 1 is carried over to the next column.








Technically the carry causes a fifth possible case:
1 + 1 + 1 = 1 (carry 1)








Here's a problem for you to solve on your own:
10110 + 01011

Binary Subtraction

There are four cases for binary subtraction:
0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
0 - 1 = 0 (Borrow 1)









Here's a problem for you to solve on your own:
1101 - 0011

Binary Multiplication

Binary multiplication is actually simpler than decimal multiplication.
There are four cases for binary multiplication (and all but one results in something other than 0):
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1









Now try this problem on your own:
11 x 10

Long Division

Division is a bit more complicated, since we use Long division for binary division. Remember that? Me neither. It was a long time since school, and I've even heard most schools stopped teaching it quite a while a go (what a shame).
So let's start with a reminder of how Long division works with a decimal example:

                      quotient       
denominator) numerator

If we have 764 / 4, we put the denominator (4), and numerator (764) as indicated in the diagram above:
   ____
4)764

We begin with calculating 7/4 (how many times does 4 fit in 7).
Obviously the result is 1, and is noted above, in the location for the quotient.
We then multiply the denominator with that number: 4 x 1 =  4. This is the number to be subtracted from 7, which results in 3, and is noted below.
These are the steps that must be repeated in order to calculate the entire problem.

We then move the next figure down; this is the 6 in 764.
We now calculate 36/4, which is 9, and jot it down as the next figure for the quotient.
4 x 9 = 36, which is written on the next row, the result of 36-36=0 (This is of course because 4 goes in 36 an even 9 times, without a remainder).

We now move the 4 from 764 down, and calculate 4/04, which of course is 1, and add it to the quotient. And now we calculate 4x1=4 (again, because 4/4 leaves no remainder), and 4-4=0.

Thus the result of 764/4 is 191.

In case the last expression would not have been even, and did leave a remainder, the whole procedure would continue by adding a decimal point to the quotient.

Binary Division

Now binary division should be no problem for you, as long as you understand how long division, and binary subtraction works.

For this example we use 101110/10 (22/2 in decimal).

First we check 1 is greater than or equal to 10, which it's not, so we add 0 to the quotient.
Then we check if 10 is greater than or equal to 10, and it is, so we add 1 to the quotient.
Now we take down the 10 and get 10-10. If you remember the binary subtraction this results in 00.
Since 00 is not greater than or equal to 10, we bring down the 1 from the numerator.
1 is not equal to or greater than 10, so we add 0 to the quotient, and take down the next 1 from the numerator.
Now 11 is greater than 10, so we add 1 to the quotient, and again subtract 10, this time from 11 (11-10 = 01). Again 1 is not equal or greater than 10, so we bring down the next 1 from the numerator, and again we get 11, which is greater than 10, so we add a 1 to the quotient, and again we subtract 10 from 11 (which is still 01).
1 is not greater or equal to 10, so again we need to bring down the next figure from out numerator, which is 0.
Now we compare 10 to 10, which is equal, so we add a 1 to the quotient.

And finally, if we subtract 10 by 10 we get 00, which means we get no remainder.
If the final subtraction does not equal 0, the result of that subtraction is the remainder of the calculation.

Comments

Popular posts from this blog

Carolus Rex

BASIC

Binary Numeral System