How do you convert numbers into binary code (zeros and ones)
Hi there,
I think I'd better try and expain a little what binary is first,
and then give an example of how to make a binary "code".
We represent numbers all the time by using the symbols 0, 1, 2,
..., 9: e.g. the number 47 bus, the guitar strings on sale for
£5.99, etc. Binary is another way of representing a number.
This may seem a bit strange at first, but if it does, then think
about 1/2: we know that 1/2 and 0.5 are the same number, but we
have two different ways of writing it down. (i.e. the same number
can be written more than one way)
Now let's just concentrate on whole numbers, because they are so
much easier to deal with! Now, what do I mean when I say the number
"47" ?
What we mean by "47" is:
4 lots of 10 +
7 lots of 1
Similarly for "2345" :
2 lots of 1,000 +
3 lots of 100 +
4 lots of 10 +
5 lots of 1
Now binary is just a different way of splitting numbers up so we
can represent them. Instead of using 1s, 10s, 100s, and 1,000s we
use 1s, 2s, 4s, 8s, 16s, etc. Can you see a pattern in these
numbers ? If so, what is it ?
Now if we try splitting 2345 up into lots of 1, 2, 4, ... we
get:
1 lot of 2048 +
1 lot of 256 +
1 lot of 32 +
1 lot of 8 +
1 lot of 1
if we note that there are also:
zero lots of 1024,
zero lots of 512,
zero lots of 128,
zero lots of 64,
zero lots of 16,
zero lots of 4, and
zero lots of 2
Then we can write 2345 in binary as:
2345 = 100100101001
Note the order:
No. of 2048's, then no. of 1024's, then no. of 512's, then ...,
then no. of 1's
Can you see how you could do the sam thing for some simple numbers
like 14 and 47 ?
After you've done this, try a bigger number like 2345.
If you're interested, there's a big connnection between binary and
computers, since (as you can see ?) binary only uses 1's and 0's,
and we can make a computer interpret the presence of electricity as
a "1", and the absence of it as a "0", so that computers can work
with numbers using binary. In fact, there's a discussion about
computers & maths just started up in the "What use is Maths ?"
section, which you can get to by clicking here.
If there's anything you don't understand, or would like me to
explain further, just pop up another email.
I hope this is of some help to you !
Andrew R
PS I have been a bit vague about the connection between computers
and binary. The computer actually uses the presence or absence of
voltages to determine whether a signal is a "1" or a "0". However,
I don't know how much Physics you know, so if this is gobbledygook
to you, then either ignore it, or ask me and I'd be happy to
explain !