Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (3)

Powered by Vanilla. Made with Bootstrap.
Numbering Systems
  • after seeing NullSet's thread about integers i decided to add this old article i had written on the different numbering systems used

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Author: CrashOverron
    ; Date: 09/29/08
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ORG 0×0000

    0×01 EQU Intro
    0×02 EQU Decimal
    0×03 EQU Hexadecimal
    0×04 EQU Binary
    0×05 EQU Summary

    0×01 : Intro
    Hello, this is not suppose to be a tutorial of any sort, it is merely a paper to help the reader understand the concept of the different numbering systems.
    There are three (3) main types of numbering systems seen being covered here: decimal (255), hexadecimal (FF), binary(11111111). To start off, the most
    common that everyone learns, even those not into computers, is the decimal system.

    0×02 : Decimal
    The decimal number system is quite easy for us to figure out because it is the one most people use when calculating typical mathematical equations.
    This system of numbers is calculated by something called base 10. The easiest way to explain this is by example in my opinion so here it goes, say we
    we have 255 so to write this out we have (2 x 10^2) + (5 x 10^1) + (5 x 10^0). With decimal it doesn't serve much purpose since we already know 255 = 255
    but it does help to understand the concept, so lets move on to something where we can actually see how this helps.

    0×03 : Hexadecimal
    Hexadecimal is similar to decimal except instead of going from 0 – 9 it goes 0 – F, or in other words 0 – 15 ( 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F ). Since hex has sixteen
    possibilities it is calculated by base 16 similar to the decimal base 10. For an example of converting hexadecimal into decimal we simply do like we did before
    except change the base, if we take FF in hex and then calculate out (F x 16^1) + (F x 16^0) it would be similar to us writing (15 x 16^1) + (15 x 16^0) which if you
    calculated out would be (240) + (15) = 255 which is the highest number you can count to in one byte of hexadecimal, we will get more into the parts of the byte in
    the next section.

    0×04 : Binary
    Binary, like hexadecimal, can only count to 255 including 0 giving a total of 256. Though unlike the previous numbering systems binary only has two possibilities
    for each position a one or zero. Because it only has those two possibilities binary is calculated in base 2. Binary has a total of eight position, which is actually
    called a bit, that equal a byte (four bits equals a nibble) displayed as 00000000. In order to convert this we simply do as we did with the prior two systems, if we
    have 11111111 we calculate (1 x 2^7) + (1 x 2^6) + (1 x 2^5) + (1 x 2^4) + (1 x 2^3) + (1 x 2^2) + (1 x 2^1) + (1 x 2^0) which is equivalent to
    (128) + (64) + (32) + (16) + (8) + (4) + (2) + (1) = 255. It may also be noted that each following position is half the value of the previous (reading from left to right).

    0×05 : Summary
    Hopefully, after reading this it is much easier to understand how to convert hexadecimal and binary into their decimal equivalences. As I said at the beginning,
    this was not meant to be a tutorial or anything of that sort just trying to help demystify the couple of different way of counting. Hope you learned something and
    enjoyed it!

    END
  • Flashlight
    Posts: 173
    Technically 1111 1111 is equal to -1
  • sangf
    Posts: 203
    said:


    Technically 1111 1111 is equal to -1



    assuming two's complement representation of _numbers_, not unsigned :3
  • Deque
    Posts: 78

    Binary, like hexadecimal, can only count to 255 [...] Binary has a total of eight position


    That is just wrong.

    I am also missing, why these number systems are used and how to convert them back to decimal.
  • sangf
    Posts: 203
    said:


    Binary, like hexadecimal, can only count to 255 [...] Binary has a total of eight position


    That is just wrong.

    he did specify it was for a byte in the hex section, but i guess that's not much of an excuse; the intro to the binary section isn't the best worded description (in fact mentioning bytes here would be more relevant than the hex section, since they are binary 'terms', ie. bunch of bits (_binary_ digits)).
  • Null Set
    Posts: 112
    said:


    ...why these number systems are used and how to convert them back to decimal.



    Simple:

    remember how:

    123 = 1 x 10^2 + 2 x 10^1 + 3 x 10^0 ?


    The same logic goes for binary:
    123 = 01111011

    And, since binary is "base 2":

    01111011
    = 0 x 2^7 + 1 x 2^6 + 1 x 2^5 + 1 x 2^4 + 1 x 2^3 + 0 x 2^2 + 1 x 2^1 + 1 x 2^0
    = 0 + 64 + 32 + 16 + 8 + 0 + 2 + 1
    = 123 (decimal)


    If you're applying it to any other base system, like hexadecimal, just follow the same principle:

    let i = Base number

    WXYZ = number in a certain base system

    converting to decimal, we just need to get the sum of:

    W x i^3 + X x i^2 + Y x i^1 + Z x i^0


    I hope this helps, Deque :)
  • Deque
    Posts: 78
    Null Set, I know this stuff. I am a computer science grad. I am just saying that this tutorial needs to be improved.
  • Null Set
    Posts: 112
    said:


    Null Set, I know this stuff. I am a computer science grad. I am just saying that this tutorial needs to be improved.



    Sorry misunderstood. :P well, maybe what i wrote can be an addition to Crash's article. Meant no insult of your skill.