Adblock breaks this site

Simple binary and hexadecimals tut

Discussion in 'Programming General' started by ignite7, Jun 6, 2007.

  1. ignite7

    ignite7 Forum Addict

    Joined:
    Jul 19, 2006
    Posts:
    606
    Referrals:
    0
    Sythe Gold:
    0
    Simple binary and hexadecimals tut

    Binary and Hexadecimal

    Binary System:


    Convert Binary to Decimal:

    Systax: "Value x 2 ^ Position"
    1. Value = Number converting
    2. x = Multiplication
    3. 2 = Binary Base
    4. ^ = Exponent
    5. Position = Position in the whole number you are converting(Right To Left)
    Convert:

    * 1 x 2 ^ 0 = 1
    * 1 x 2 ^ 1 = 2
    * 0 x 2 ^ 2 = 0
    * 0 x 2 ^ 3 = 0
    * 1 x 2 ^ 4 = 16

    Steps To Converting:

    1. Write the number down from Right to Left.
    2. Multiply each single number by the Binary Base(2).
    3. Then to the power (^) of its Position.
    4. Take the final numbers from each Position and add them.

    Answer:

    The answer for this should 19. If it is not then you have done something wrong.
    11001 or 10011
    1 + 2 + 0 + 0 + 16 = 19 In Decimal.

    Convert Decimal to Binary:
    Systax: "Value / 2 Remainder"
    1. Value = Starting Number to Convert.
    2. / = Division.
    3. Remainder = The Remainder(lol).
    Convert:

    * 238 / 2 Remainder: 0
    * 119 / 2 Remainder: 1
    * 59 / 2 Remainder: 1
    * 29 / 2 Remainder: 1
    * 14 / 2 Remainder: 0
    * 7 / 2 Remainder: 1
    * 3 / 2 Remainder: 1
    * 1 / 2 Remainder: 1
    * 0 / 2 Remainder: 0

    Steps To Converting:
    1. Divide the Original number by 2, If it divides evenly the Remainder will be 0.
    2. Divide the answer from the previous calculation by 2.
    3. If it wont Divide evenly the Remainder will be 1.
    4. Round the number from the previous calculation DOWN, And divide it by 2.
    5. Repeat this process until you get to 0.
    Answer:
    The final answer should be "011101110", As you may notice how the answer given is missing the 1st 0.
    That's because just like in Decimal, they have no value and can be omitted, So 045 is same as 45.

    Additional things about Binary:

    * Usually 1 represents true, and 0 represents false.
    * When writing Binary, keep the number in multiples of 4.
    * EX 1: "0000:0000" without the ':'.
    * EX: Don't write 11001 this is incorrect, change it to 00011001, And remember that the zero's in front are not worth anything.
    * Usually you add a 'b' after the number to signal the fact that it is a Binary number.
    * EX: 00011001 = 00011001b.


    Converting Hexadecimal:

    Convert Hexadecimal to Decimal:
    Systax: "Value x 16 ^ Position"

    1. Value = Value of the number you are converting.
    2. x = Multiply
    3. 16 = Hexadecimal Base
    4. ^ = Exponent
    5. Position = Position in the whole number you are converting.

    Convert:


    * F x 16 ^ 0 = 15 x 1 = 15
    * 4 x 16 ^ 1 = 4 x 16 = 64
    * A x 16 ^ 2 = 10 x 256 = 2560
    * 2 x 16 ^ 3 = 2 x 4096 = 8192


    Steps To Converting:

    1. Write the number down from Right to Left.
    2. Multiply the number by the Hexadecimal Base(16)
    3. Then to the power of it's Position


    Convert Decimal to Hexadecimal:
    Systax 1: "Value / 16"

    * Systax 1:
    * Value = Whole Number
    * / = Divide
    * 16 = The base of Hexadecimal

    Systax 2: "Value x 16"

    * Systax 2:
    * Value = Whole Number
    * x = Multiply
    * 16 = The base of Hexadecimal

    Systax 3: "Number - Value"

    * Systax 3:
    * Number = Number left from Systax 2
    * - = Subtact

    Convert:
    A

    * 1324 / 16 = 82.75
    * 82 x 16 = 1312
    * 1324 - 1312 = 12
    * Converted to Hexadecimal: C

    B

    * 82 / 16 = 5.125
    * 5 x 16 = 80
    * 82 - 80 = 2
    * Converted to Hexadecimal: 2

    C

    * 5 / 16 = 0.3125
    * 0 x 16 = 0
    * 5 - 0 = 5
    * Converted to Hexadecimal: 5

    Steps To Converting:
    A

    1. Systax 1a: Divide The whole number with the Hexadecimal Base(16).
    2. Systax 1b: Multiply what you have left from Systax 1a by the Hexadecimal Base(16).
    3. Systax 1c: Subtact The number from Systax 1b From the whole number.

    B

    1. Take the number you got from Systax 1a.
    2. Systax 2a: Divide this number with the Hexadecimal Base(16).
    3. Systax 2b: Multiply what you have left from Systax 2a by the Hexadecimal Base(16).
    4. Systax 2c: Subtact The number from Systax 1a from Systax 2b.

    C

    1. Take the number you got from Systax2a.
    2. Systax 3a: Divide this number with the Hexadecimal Base(16).
    3. Systax 3b: Multiply what you have left from Systax 3a by the Hexadecimal Base(16).
    4. Systax 3c: Subtact The number from Systax 2a from Systax 3b.
     
  2. DarkLordX

    DarkLordX Guest

    Referrals:
    0
    Simple binary and hexadecimals tut

    thanks this is helping me alot
     
< How do i fix this | programing for runescape mills >


 
 
Adblock breaks this site