Numbering Systems - Conversions
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Numbering Systems - Conversions

  1. #1
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914

    Numbering Systems - Conversions

    Numbering Systems
    Note: I have searched the tutorials forms and not found anything like this, If i'm stepping on anyones toes, or posting information already available neg me to death and i'll delete it. Anyways here you go. I had to do a numbering system tutorial for my fellow students, hopefully this will help ya'll out.

    Decimal - The decimal numbering system is what we all know and use. It contains 10 digits (0 - 9) and then columns representing ones (10^0), tens(10^1), hundreds(10^2), thousands(10^3) and so on.
    Binary - On and Off... A One or a Zero. This is the system that computers know and recognize. It contains 2 digits (0 - 1) and columns representing powers of 2. One (2^0), two ((2^1), four (2^2), 8 (2^3) and so on.
    Octal - A number system using 8 digits (0 - 7). It is now considered to be somewhat archaic and is no longer used as much as it was in the past. The columns in octal represent powers of 8. One (8^0), 8 (8^1), 64(8^2) and so on.
    Hex - A number system using 16 digtals (0 - 9 and A - F)... The letters represent the numbers 10 (A) - 15 (F). Hex is used all the time in the computer world. In MAC Addresses and Packet Captures, in programming, and in IPv6. The columns in hex represent powers of 16. One (16^0), 16 (16^1), 256 (16^2) and so on.

    All number systems follow the same method to determine the number. You multiple the Value of the digit in the column by the value of the column

    10 in decimal is 1 x 10^1 + 0 x 10^0
    1010 in Binary is 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 0 x 2^0
    12 in Octal is 1 x 8^1 + 2 X 8^0
    A in Hex is 10 x 16^0

    Now obviously the values that are 0 x ?? are not necessary, but even so, a big number can be a pain in the ass to convert. Conversion between binary and decimal is by far the easiest. With a binary number you can make a chart at first, but after a while the calculations can be done in your head.

    To convert 10 (Decimal) to Binary. First write out the values of the binary columns (like below). Now work your way down the chart to the biggest number that goes into 10. The answer is 8, so put a 1 there. Fill in all spaces before the 1 with 0s. 10 - 8 = 2. So now find a number that will go into 2. 4 won't so the next one is 2.... put a 1 there and 0s in between. 2 -2 = 0.. you're done so put 0s in all the remaining spots

    2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
    128 64 32 16 8 4 2 1
    0 0 0 0 1 0 1 0

    00001010 (you can drop all the leading 0s so your answer is 1010).

    To convert the number back into decimal you would do the reverse process. Make the chart, and write the binary number in the columns. Then just add up all the column values where you put a 1.

    How that we've done that.. let's look at converting octal and hex. The pattern for these two number systems is very similar.

    The largest hex number is F which is 15 in decimal or 1111 in binary.
    The largest octal number is 7 which is 7 in decimal or 111 in binary.

    The pattern should seem obvious. Cut your Binary numbers into chunks. if you have the number 10101010 = 170 (decimal).
    To conver to hex, cut it into 2 chunks of 4. 1010 and 1010. Here is a chart of how hex values compare to binary values.
    0 - 0000
    1 - 0001
    2 - 0010
    3 - 0011
    4 - 0100
    5 - 0101
    6 - 0110
    7 - 0111
    8 - 1000
    9 - 1001
    A - 1010
    B - 1011
    C - 1100
    D - 1101
    E - 1110
    F - 1111

    So if we take our first chunk of 4 bits we see 1010 which on our chart is A, the second chunk is also 1010 so it is A again. So our hex solution is AA.
    Hex numbers can also be converted backwards this way... say you had the number 3C. 3 in hex is 0011 in binary and C in hex is 1100 in binary. So your solution is 00111100, which if you convert it using your chart:
    2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
    128 64 32 16 8 4 2 1
    0 0 1 1 1 1 0 0

    Add up the columns and you get 60 in decimal.

    Now if we move to octal. Our chart is the first 8 digits of the hex chart:
    0 - 000
    1 - 001
    2 - 010
    3 - 011
    4 - 100
    5 - 101
    6 - 110
    7 - 111

    If we work with the same number again, 10101010, for octal we break it into chunks of 3. We only have 8 digits so add an additional 0 to make it a mulitple of 3
    010101010.. now we break that up and get 101 101 010
    If we compare that to our chart, we get 2 for each chunk... or 252.

    Again we can convert the octal back using this method... If we use 74.. We can break this up using the chunk method. We get 111 and 100, so the binary number 111100. We plug this into our chart and come up with

    2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
    128 64 32 16 8 4 2 1
    0 0 1 1 1 1 0 0

    Add up the columns and you get 60 in decimal.

    Now you should be able to easily convert numbers between any base. I hope you all find this somewhat useful.

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    Note: I have searched the tutorials forms and not found anything like this,
    Not a tutorial, but...
    http://www.antionline.com/showthread...484#post605638

    EDIT: Oh, there is one,
    http://www.antionline.com/showthread...hreadid=230551

    Peace always,
    <jdenny>
    Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
    I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds


  3. #3
    Senior Member
    Join Date
    Feb 2003
    Posts
    211
    Good job HTRegz .. i ever learnt it in college .
    here's the BCD ( Binnary Code Decimal ) and how to convert the Binnary to BCD.
    anyway this is a good post.. well done mate.

    When I lay me down to sleep, Pray the LORD my soul to keep.
    If I die before i wake, Pray the LORD my soul to take.

    http://www.AntiOnline.com/sig.php?imageid=389

  4. #4
    Member
    Join Date
    Oct 2002
    Posts
    37
    1010 in Binary is 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 0 x 10^2
    I believe the last part should be .....+ 0 x 2^0

    But overall very nice. I would recommend this be moved to the tutorial section. Its simplistic and to the point, anyone should be able to grasp it.

    Good job HTRegz
    The only limit a person has, is the limit they give themselves.
    Cogito ergo sum. - Descartes

  5. #5
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914
    Thanks everyone...

    And thanks for pointing out the typo Shadowmeld I've correct it... I typed this out in 5 minutes in notepad.. i was cutting and pasting at times must have missed one of them...

  6. #6
    Banned
    Join Date
    Jan 2003
    Posts
    95
    Good post mate. I am here going to complete list of symbols. Here is Two popular coding schemes are ASCII AND EBCDIC which is stands for American Standard Code for Information Interchange(ASCII) Extended Binary Coded Decimal Interchange Code(EBCDIC)

    ASCII SYMBOL EBCDIC
    00110000 0 11110000
    00110001 1 11110001
    00110010 2 11110010
    00110011 3 11110011
    00110100 4 11110100
    00110101 5 11110101
    00110110 6 11110110
    00110111 7 11110111
    00111000 8 11111000
    00111001 9 11111001
    01000001 A 11000001
    01000010 B 11000010
    01000011 C 11000011
    01000100 D 11000100
    01000101 E 11000101
    01000110 F 11000110
    01000111 G 11000111
    01001000 H 11001000
    01001001 I 11001001
    01001010 J 11010001
    01001011 K 11010010
    01001100 L 11010011
    01001101 M 11010100
    01001110 N 11010101
    01001111 O 11010110
    01010000 P 11010111
    01010001 Q 11011000
    01010010 R 11011001
    01010011 S 11100010
    01010100 T 11100011
    01010101 U 11100100
    01010110 V 11100101
    01010111 W 11100110
    01011000 X 11100111
    01011001 Y 11101000
    01011010 Z 11101001
    00100001 ! 01011010
    00100010 " 01111111
    00100011 # 01111011
    00100100 $ 01011011
    00100101 % 01101100
    00100110 & 01010000
    00101000 ( 01001101
    00101001 ) 01011101
    00101010 * 01011100
    00101011 + 01001110

  7. #7
    Banned
    Join Date
    Jan 2003
    Posts
    95
    Good post mate. I am here going to complete list of symbols. Here is Two popular coding schemes are ASCII AND EBCDIC which is stands for American Standard Code for Information Interchange(ASCII) Extended Binary Coded Decimal Interchange Code(EBCDIC)

    ASCII SYMBOL EBCDIC
    00110000 0 11110000
    00110001 1 11110001
    00110010 2 11110010
    00110011 3 11110011
    00110100 4 11110100
    00110101 5 11110101
    00110110 6 11110110
    00110111 7 11110111
    00111000 8 11111000
    00111001 9 11111001
    01000001 A 11000001
    01000010 B 11000010
    01000011 C 11000011
    01000100 D 11000100
    01000101 E 11000101
    01000110 F 11000110
    01000111 G 11000111
    01001000 H 11001000
    01001001 I 11001001
    01001010 J 11010001
    01001011 K 11010010
    01001100 L 11010011
    01001101 M 11010100
    01001110 N 11010101
    01001111 O 11010110
    01010000 P 11010111
    01010001 Q 11011000
    01010010 R 11011001
    01010011 S 11100010
    01010100 T 11100011
    01010101 U 11100100
    01010110 V 11100101
    01010111 W 11100110
    01011000 X 11100111
    01011001 Y 11101000
    01011010 Z 11101001
    00100001 ! 01011010
    00100010 " 01111111
    00100011 # 01111011
    00100100 $ 01011011
    00100101 % 01101100
    00100110 & 01010000
    00101000 ( 01001101
    00101001 ) 01011101
    00101010 * 01011100
    00101011 + 01001110

  8. #8
    Senior Member
    Join Date
    Oct 2001
    Posts
    638
    OpenBSD - The proactively secure operating system.

  9. #9
    Senior Member
    Join Date
    Oct 2001
    Posts
    638
    OpenBSD - The proactively secure operating system.

  10. #10
    Super Moderator
    Know-it-All Master Beaver

    Join Date
    Jan 2003
    Posts
    3,914
    Well i from smirc's post I owe a few people apologies... but now i'm kinda curious... does the search only work with posts back a certain date? I'm here typing binary and tutorial in the search engine and those threats still aren't coming up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides