
                                                     
                                                       
               ۰߰     ܰ۰  
             ۱      ܱ߰    ۰
             ۱          ۱      ۰  
                 ܰ߱    ߰۲    
              Outbreak Magazine Issue #15 - Article 4 of 11
          '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'


****************************************
* Binary Bafflement                    *
*                   		       *
* Written by GPC		       *
* On 21:08 08/03/03		       *
* heelflip_the_biscuit_tin@hotmail.com *
*				       *
****************************************

This text has one purpose and one purpose only. To get you a higher
mark on the hacker purity test (cos thats what we all want from life).
Basically, from what meagre evidence I have gathered, the most unanswered 
bit
of the purity test is the question about binary and denary stuff. Well
here's a little guide that should sort you out there.

* BINARY
The method of converting denary to binary and back is amazingly simple and 
I'll
outline it here before this text sounds any more like a textbook.

         |  128  |  64  |  32  |  16  |  8  |  4  |  2  |  1  |

Binary is split up like so and all we have to do is put a '1' below the 
column
in which section's number is the largest that is smaller than out denary
number. Sound confusing? Well it isn't, if we take 10 as our number to be
converted we can see that it is smaller than 128, 64, 32 and 16 so we put a
'0' in those columns:

         |  128  |  64  |  32  |  16  |  8  |  4  |  2  |  1  |
         |   0   |  0   |  0   |  0   |     |     |     |     |

Now, 10 is bigger than 8 so we can put a 1 in the 8 section:

         |  128  |  64  |  32  |  16  |  8  |  4  |  2  |  1  |
         |   0   |  0   |  0   |  0   |  1  |     |     |     |

That leaves us with 2 (10 - 8). Now, 2 is smaller than 4 so we put a '0' 
there:

         |  128  |  64  |  32  |  16  |  8  |  4  |  2  |  1  |
         |   0   |  0   |  0   |  0   |  1  |  0  |     |     |

Now, 2 happens to be exactly the number we want so we put a '1' in that 
column
and fill the rest of the columns in with '0' (just in section 1 in this 
case):

         |  128  |  64  |  32  |  16  |  8  |  4  |  2  |  1  |
         |   0   |  0   |  0   |  0   |  1  |  0  |  1  |  0  |

This gives us the binary number 00001010. Simple huh? Another point to note
(although the shrewd mathematicians will have already worked it out) is that
the maximum number that this structure can hold is 256.

To work from binary to denary is just a case of reversing the steps.

* B.C.D.
BCD or Binary Coded Decimal works in almost the same way as binary but here
you are calculating the binary code for each digit, not the whole number. If
we take the number 724 BCD works like so:

	 |  8  |  4  |  2  |  1  |

You work out the binary for each digit (7, 2, 4) so it chould look like 
this:

	 |  8  |  4  |  2  |  1  |    } Digit
         |  0  |  1  |  1  |  1  |    } '7'

	 |  8  |  4  |  2  |  1  |    } Digit
         |  0  |  0  |  1  |  0  |    } '2'

	 |  8  |  4  |  2  |  1  |    } Digit
         |  0  |  1  |  0  |  0  |    } '4'

So you've got 0111 0010 0100, that's the BCD for 724. Once again, to do it 
the
other way, just reverse the steps.

* Questions
1. Convert these denary numbers to binary
a) 4
b) 54
c) 200

2. Convert these denary numbers into BCD
a) 9
b) 100
c) 692

* Answers
1.
a) 00000100
b) 00110110
c) 11001000

2.
a) 1001
b) 0001 0000 0000
c) 0110 1001 0010

Well there we go, I hope you've all learnt something. Now go get a higher 
mark
in the hacker purity test (and if you haven't taken it, find it at
www.textfiles.com). Any comments / suggestions e-mail me at
heelflip_the_biscuit_tin@hotmail.com

	- GPC
