-
October 27th, 2002, 12:49 PM
#1
conversion of various number bases
well here is my first (and i hope not last) tute on AntiOnline
how to convert between various numbering systems:
i'll start by going from base 2 (binary) to assorted other formats and will add more as i go
base 2 (binary)--> base 16 (hex)
as we all know, binary uses 1's and 0's to represent numbers, and hex uses numbers from 0 - 9 and letters from A - F
binary (2) hex (16) decimal (10) octal (8)
0000 0 0 0
0001 1 1 1
0010 2 2 2
0011 3 3 3
0100 4 4 4
0101 5 5 5
0110 6 6 6
0111 7 7 7
1000 8 8
1001 9 9
1010 A 10
1011 B 11
1100 C 12
1101 D 13
1110 E 14
1111 F 15
to go from binary to hex, get your binary number e.g. 1111 0111
split it into groups of four digits, if you get a group which isnt four digits, add 0's to the right side until it is 4 digits long
now back to our example 1111 0111 becomes F7 according to the above table
to go from hex to binary, simply refer to the above conversion chart and reverse the above procedure:
ie F becomes 1111 and 7 becomes 0111
to convert hex to decimal we do this:
use the hex number codes to correspond them to decimal numbers ie f is 15, 7 is 7 etc
and reading from right to left in powers of 16 starting from 16 ^0, 16 ^1 etc
so F7 becomes (F x 16 ^1) + (7 x 16 ^0)
--> (F x 16) + 7
--> 247 decimal
to convert decimal to hex, the easiest way i know of is to convert to binary and then convert to the hex numbers using the conversion chart above
To make our original binary number octal, we just split the binary number into groups of 3 instead of 4
so 11110111
is split to 111 101 011 (hope that is right)
then you convert your groups of 3 binary numbers to their corresponding octal's
so 111 101 011 becomes:
753
to convert octal to binary, you simply reverse the above procedure and add zero's to the left side of any odd groups
Octal to decimal uses the same idea as converting decimal to hex, convert your octal to binary, then convert the binary number to decimal
any other parts i may have missed can be done using the above ideas and the conversion chart above, hope this is of help to someone out there
MrLeachy
-
October 27th, 2002, 06:34 PM
#2
Ok, now, you can easily say me in what base my signature is converted.
One little indication: I used the ASCII code.
Life is boring. Play NetHack... --more--
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|