1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I need Help with Binary!!

Discussion in 'General Programming Chat' started by satyawrat, Sep 20, 2010.

  1. satyawrat

    satyawrat Jr. VIP Jr. VIP

    Joined:
    Jul 8, 2009
    Messages:
    919
    Likes Received:
    1,181
    Occupation:
    Hustler
    Location:
    Gurgaon
    Home Page:
    I am starting out with programming and all other geeky stuff. I have started larning. But I have some confusion with binary...

    I used a binary translator here: http://home2.paulschou.net/tools/xlate/

    What I don't get is:
    1 ---> 00110001 in binary
    I get the "0001" thing..
    BUT
    Why are there "1" placed in 32s and 16s place? here: 00110001???:yell:
     
  2. satyawrat

    satyawrat Jr. VIP Jr. VIP

    Joined:
    Jul 8, 2009
    Messages:
    919
    Likes Received:
    1,181
    Occupation:
    Hustler
    Location:
    Gurgaon
    Home Page:
    hmmm... not many geeks on BHW? only marketers ground?
     
  3. satyawrat

    satyawrat Jr. VIP Jr. VIP

    Joined:
    Jul 8, 2009
    Messages:
    919
    Likes Received:
    1,181
    Occupation:
    Hustler
    Location:
    Gurgaon
    Home Page:
    Figured it out myself.
    1 ----> 00110001 is correct because the translator is treating "1" as a string and not a base 10 number.
    I tried another translator in which I had the option to select the input. I selected base 10 to base 2 and the output was correct.
     
  4. helpnub

    helpnub Registered Member

    Joined:
    Jan 2, 2008
    Messages:
    72
    Likes Received:
    43
    Binary base 2 right

    Starting from the right 2 power 0, 2 power 1, 2 power 2 etc
    ie 1 2 4 8 16 32 64 128 etc

    entering text '1' is represented by decimal 49 = 0x256 + 0x128 + 0x64 + 1x32 + 1x16 + 0x8 + 0x4 + 0x2 + 1x1 i.e. 00110001
     
    • Thanks Thanks x 1
  5. fbcoder

    fbcoder Newbie

    Joined:
    Sep 16, 2010
    Messages:
    37
    Likes Received:
    5
    Yep, the above is correct.

    Basically we have 10 base. (10,100,1000)

    Binary uses 2 Base.

    Code:
    11001101
    It would be broken down into the following.
    ON(1) ON(1) OFF(0) OFF(0) ON (1) ON (1) OFF (0) ON (1)
    So you can see on is represented by a 1.

    If it is a ON then you simply do 2 To the power of the number it is on the line..

    2^7, 2^6, 2^5, 2^4, 2^3, 2^2, 2^1, 2^0

    ^ = power to.

    So for our example
    Code:
    11001101
    It is. (Work from left to right)
    2^7 + 2^6 + 0^5 + 0^4 + 2^3 + 2^2 + 0^1 + 2^0

    A simplier way is to only had the values with an ON.

    So,
    2^7 + 2^6 + 2^3 + 2^2 + 2^0

    In both situations you get 205.

    205 is then the ascii code, for the character.

    You can find out the ascii code from the ascii chart.
     
    • Thanks Thanks x 1
  6. hamd01

    hamd01 Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 29, 2010
    Messages:
    560
    Likes Received:
    127
    Mate, there are 10 kinds of people in this world. Those who understand bindary, and those don't!
     
    • Thanks Thanks x 1
  7. satyawrat

    satyawrat Jr. VIP Jr. VIP

    Joined:
    Jul 8, 2009
    Messages:
    919
    Likes Received:
    1,181
    Occupation:
    Hustler
    Location:
    Gurgaon
    Home Page:
    Ok!How would one write 256?

    00000001 11111111 -----> 1 255 not 256??
    How??
     
  8. fbcoder

    fbcoder Newbie

    Joined:
    Sep 16, 2010
    Messages:
    37
    Likes Received:
    5
    Code:
    10000000
     
    • Thanks Thanks x 1
  9. satyawrat

    satyawrat Jr. VIP Jr. VIP

    Joined:
    Jul 8, 2009
    Messages:
    919
    Likes Received:
    1,181
    Occupation:
    Hustler
    Location:
    Gurgaon
    Home Page:
    Thats 128 not 256!!!
    Oh! But I got the idea now, you just missed one zero by mistake...:)
     
  10. fbcoder

    fbcoder Newbie

    Joined:
    Sep 16, 2010
    Messages:
    37
    Likes Received:
    5
    Yep, just missed one zero sorry.