Maybe Educational? Mostly Regret
Number Systems!
What are number systems? Number systems are a series of
numbers and sometimes letters that we use to record things and to store data.
There is more than just one number system that is used nowadays and they would
be Decimal, Binary, and Hexadecimal.
Decimal
The Decimal number system is one that everybody knows as
it is the number system that everybody is taught and uses. It has a base of 10
and uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Computers really don't like
this system whereas people like it quite a bit and find it easy to understand.
Binary
The Binary number system is the one that computers use.
It has a base of 2 and uses the digits 0, 1. Computers like this system because
they operate solely through the use of on and off states, or 1s and 0s.
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
128s |
64s |
32s |
16s |
8s |
4s |
2s |
1s |
Hexadecimal
The Hexadecimal number system is used for RAM in
computers and for RGB colour codes. It has a base of 16 and uses the digits 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, A, B, C, D, E, F.
167 |
166 |
165 |
164 |
163 |
162 |
161 |
160 |
268 435 456s |
16 777 216s |
1 048 576s |
65 536s |
4096s |
256s |
16s |
1s |
Converting Decimal to Binary
To convert from decimal to binary, all you need to do is
some simple division and subtraction. The first thing we do is take the number
and figure out which two places it’s between (ex. 27 is between 16 and 32),
then we take the smaller one and divide the number by it, which will be either
1 or 0, then we take the remainder and divide it by the next smaller place (ex.
8 is the next smaller place value after 16) and continue until you get to 1.
Then you put all your 1’s and 0’s and put them in order left to right starting
with the first one you figured out.
Let’s convert the decimal number 27 into binary:
27 / 16 = 1 r:11
11 / 8 = 1 r:3
3 / 4 = 0 r:3
3 / 2 = 1 r:1
1 / 1 = 1 r:0
2710 = 110112
Converting Binary to Decimal
To convert from binary to decimal, all you need to do is
some simple addition and multiplication. The first thing you do is take the 1
or 0 farthest to the right and in brackets write 1 or 0 (depending on what it
is in you binary number) and multiply it by 20. Then you add another
set of brackets to the equation and in those brackets you write 1 or 0
(depending on what it is in you binary number) and multiply it by 21
(add 1 to what the exponent was before), and continue doing this until you
cover every 1 or 0 in the binary number.
Let’s convert 100102 into decimal:
(0 * 20) + (1 * 21) + (0 * 22)
+ (0 * 23) + (1 * 24)
=0 + 2+ 0 + 0 + 16
=18
Converting Decimal to Hexadecimal
To convert from decimal to hexadecimal, all you need to
do is some simple division and subtraction. The first thing we do is take the
number and figure out which two places it's between (ex. 357 is between 256 and
4096), then we take the smaller one and divide the number by it, which will be
1 -15, then we take the remainder and divide it by the next smaller place (ex.
16 is the next smaller place value after 256) and continue until you get to 1.
Then you put all your numbers and put them in order left to right starting with
the first one you figured out, don't forget to translate 10 into A, 11 into B,
12 into C, 13 into D, 14 into E, 15 into F.
Let’s convert 1768 into Hex:
1768 / 256 = 6 r:232
232 / 16 = 14 r:8 14
= E
8 / 1 = 8 r:0
176810 = 0x6E8
Converting Hexadecimal to Decimal
To convert from hexadecimal to decimal, all you need to
do is some simple addition and multiplication. The first thing you do is take
the first number or letter farthest to the right and in brackets write that
number or its equivalent (A into 10, B into 11, C into 12, D into 13, E into
14, F into 15) and multiply it by 160. Then you add another set of
brackets to the equation and in those brackets you write the next number (1 to
the left) or its equivalent (A into 10, B into 11, C into 12, D into 13, E into
14, F into 15) and multiply it by 161 adding 1 to the previously
used exponent, and continue doing this until you cover every digit in the hex number.
Let’s convert D59
(9 * 160) + (5 * 161) + (13 * 162)
= 9 + 80 + 3328
= 341710
Converting Binary to Hexadecimal
To convert binary to hex, all you need to do is some
simple addition and multiplication. To start with every four digits in binary
will convert into 1 digit in hex, so you'll need to translate a chunk of 4
binary at a time. So you start at the right hand side and grab the first four,
the first being equivalent to 20, the second being 21,
the third being 22, and the third being 23. From there
you’ll each 0 as 0 and each 1 as what its equivalent to, then add the together.
Then you'll go to the next chunk of four and do the exact same thing, and keep
doing it till you're done.
Let’s convert 1011 0010 into Hex:
1011 = 23 + 0 + 21 + 20
= 8 + 0 + 2 + 1
= 11 = B
0010 = 0 + 0 + 21 + 0
= 2
1011 00102 = 0x B2
Converting Hexadecimal to Binary
To convert hex to binary, all you need to do is some
simple addition. To start with every digit in hex will translate to 4 digits in
binary. One thing you’ll need to know ahead of time is that the organization of
the 4 digit binary code for each digit in hex goes 8 4 2 1 (ex. 8421 = 11112,
8001 = 10012, 0021 = 00112). So we go on to take the
first digit in the hex number (ex. D which equals 13) and figure out what
combination of 8, 4, 2, and 1,(using only one of each)\ will add up to that
number (ex. 8+4+1 = 13), then put 1’s in the corresponding location of each
number you used and 0’s in the location of the numbers you didn’t use (ex. 13 =
8+4+1 which is 11012). You then move on to the next digit in the hex
number and do the exact same thing. Once done put all the 4 digit binary codes
together in the same order as the hex number.
Let’s convert 0xD3 into Binary:
D = 13
13 = 8 + 4 + 0 + 1
=1101
3 = 0 + 0 + 2 + 1
= 0011
0xD3 = 1101 00112
ASCII
ASCII or the American Standard Code for Information
Interchange is a lettering system that applies a numeric value to every
character used in the English language so that they can be saved as an 8-bit binary
code. It is used by most English speaking countries.
Examples:
A = 010000012 or 0x41
B = 010000102 or 0x42
a = 011000012 or 0x61
b = 011000102 or 0x62
UTF-8
UTF-8 or Unicode Transformation Format is a lettering
system that applies a numeric value to every character of just about every
language. It is both backwards compatible with most number and lettering
systems and can be as compact as ASCII if English is used. The only real
downfall with it is that when using some languages the size can become pretty
large.
A = 010000012 or 0x41
B = 010000102 or 0x42
a = 011000012 or 0x61
b = 011000102 or 0x62