I need Help with Binary!!

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

1. satyawratJr. VIPJr. VIP

Joined:
Jul 8, 2009
Messages:
1,062
1,343
Occupation:
Hustler
Location:
Gurgaon
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. satyawratJr. VIPJr. VIP

Joined:
Jul 8, 2009
Messages:
1,062
1,343
Occupation:
Hustler
Location:
Gurgaon
hmmm... not many geeks on BHW? only marketers ground?

3. satyawratJr. VIPJr. VIP

Joined:
Jul 8, 2009
Messages:
1,062
1,343
Occupation:
Hustler
Location:
Gurgaon
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. helpnubRegistered Member

Joined:
Jan 2, 2008
Messages:
72
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 x 1
5. fbcoderNewbie

Joined:
Sep 16, 2010
Messages:
37
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 x 1

Joined:
Mar 29, 2010
Messages:
561
127
Mate, there are 10 kinds of people in this world. Those who understand bindary, and those don't!

• Thanks x 1
7. satyawratJr. VIPJr. VIP

Joined:
Jul 8, 2009
Messages:
1,062
1,343
Occupation:
Hustler
Location:
Gurgaon
Ok!How would one write 256?

00000001 11111111 -----> 1 255 not 256??
How??

8. fbcoderNewbie

Joined:
Sep 16, 2010
Messages:
37
5
Code:
`10000000`

• Thanks x 1

Joined:
Jul 8, 2009
Messages:
1,062
1,343
Occupation:
Hustler
Location:
Gurgaon