Redstuff Wiki
Advertisement

Binary is a number system that is used by computers. It is a base-2 number system; it uses two digits, 1 and 0. Each number is called a bit, 4 bits are a nibble, 8 bits are a byte, 1024 bytes a KB, and 1024 KB a MB.

To help understand binary, it will be useful to go back to elementary school math. Remember that each digit of a number has a place value, which you multiply by the digit to find the value of that digit.


For example, the number 567 can be represented like this:

place value | 100 |  10 |   1
------------+-----+-----+------
digit       |   5 |   6 |   7
------------+-----+-----+------
digit value | 500 |  60 |   7

You can figure out the whole number by adding all the digit values together - in this case, 500 + 60 + 7 = 567. As you can see, each place is worth 10 times as much as the one on its right - this is why decimal is called a base-10 number system.

Binary to decimal[]

Binary numbers are very similar to decimal numbers. The main differences are that each place is worth twice as much as the one on its right instead of 10 times as much, and only the digits 0 and 1 are allowed. To convert the number 11010 to decimal, you can draw up a table like the previous one:

place value |  16 |   8 |   4 |   2 |   1 
------------+-----+-----+-----+-----+-----
digit       |   1 |   1 |   0 |   1 |   0 
------------+-----+-----+-----+-----+-----
digit value |  16 |   8 |   0 |   2 |   0

As before, you can find the number by adding all the digit values. 16 + 8 + 0 + 2 + 0 = 26, so the number is 26.

Decimal to binary[]

Converting decimal to binary is a bit harder. First, you need to find the largest place value that is less than the number - this will always be a power of two (which means you can get it by starting with 1 and doubling it some number of times). Say we want to convert 26 back to binary. We can do this using another table:

number      |  26 |  10 |   2 |   2 |   0
------------+-----+-----+-----+-----+----- 
place value |  16 |   8 |   4 |   2 |   1
------------+-----+-----+-----+-----+----- 
digit       |   1 |   1 |   0 |   1 |   0

Go from right to left, and in each place do the following steps:

  • If the number is bigger than the place value,
    • subtract the place value from the number.
    • write a 1 below it.
  • Otherwise, write a 0 below it.

The numbers 0-10 in binary[]

Binary Decimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 10

Reading And Understanding Binary[]

If the above hasn't taught you how to read binary yet, then don't worry. It will be explained in this section.

Binary is read from right to left, e.g.,

0 0 1 0 1 0 0 1

Or, as the place values are,

128 64 32 16 8 4 2 1

If you didn't notice already, the above numbers are all powers of two.

Number 0 means that the value is off. 1, therefore, means on. What that is basically saying is that you want that number. A 0 means that you don't. For example, 01001011 is saying that you want the numbers 64, 8, 2 and 1. Then you add them together to get the sum: 75.

Binary progresses in a way as illustrated in the above section, as in it fills out from the right to left.

The way and reason it fills is like this:

0000 is 0.

0001 is 1.

Then 2 is 0010.

The reason that it isn't 0011 is because when the 1 in the first slot turns off, it turns on the 1 in the second slot.

3 is 0011, and 4 is 0100.

As before, the 1 in the first slot turning off triggers a change in the next slot, which also turns off, and then to the third, which turns on.

This continues infinitely.

An example of this can be seen in CXgamer's Synchronous Counter, which is constructed of T Flip Flops in such a way that they trigger the next in a sequence.

http://www.youtube.com/watch?v=3eeDFhuI9g8

ASCII[]

Binary is also used to read and write in ASCII. ASCII is all printable and non printable characters that the computer can read, Uppercase and Lowercase.

Uppercase A is 65, or in binary, 01000001. Uppercase Z is 90, or 01011010. Each other Uppercase character is between them.

A lowercase ASCII character is written as the uppercase number, but with the 6th digit having a 1 in it. For instance, 01100001 is a.

ASCII is always written in 8 or less bits, anything higher than that and it becomes Unicode.



Binary Addition[]

There are simple rules to follow to do addition in binary.

Number 1      |  1 |  0 |   0 |   1 |   1 |
------------+-----+-----+-----+-----+   1 |
Number 2      |  0 |  1 |   0 |   1 |   1 |
------------+-----+-----+-----+-----+-----+   
Outcome       |  1 |  1 |   0 |  10 |  11 |

Other wise put as: if only one input is on the output is 1 and if there are two inputs the output is 10 (apart from 1+1+1). This can be represented with the logic gates XOR and AND. This is how we can build a binnary adder known as a half-adder:

ALU half adder

This is the electronics version. I will explain below.

The image above is really quite simple: The two inputs(getting added together) are A and B. S and C are the outputs: they stand for Sum and Carry(respectively). The two large symbols one looking like a D and the other a bit like this |D. The top one is a XOR logic gate and the bottem is a AND. If the AND gate is activated then the carry output is on and the same for the XOR with sum. The carry output is a 10 and the sum is a 1.

Here is a minecraft version which is very compact(I DIDN'T MAKE):

Alternate Half adder

Look it is animated!

This adder is very simple to build and will add two binary numbers together.

A full-adder is a machine that can 3 numbers together, this is built to create a machine that can add larger binary numbers together. It works by stringing adders together with each one representing a higher binary number, like 100 + 100 = 1000, if you remove two zero's from those numbers it is the same as 1 + 1 = 10.

Here is a design for a compact full adder I DID NOT

MAKE:

File-Full adder 2

The design works by adding 2 binary numbers together(half-adder), with the carry output going into the third input of the first full-adder and then repeating that process. You'll get it eventually.

See Also[]

http://www.asciitable.com/

Advertisement