| Author |
Binary questions |
vegeta_man111
Member
Posts: 104
Location: Ohio
Joined: 20.07.05 Rank: Apprentice |
|
ok, I am working on somehting based on binary, and I got a few questions.
1.) i read on somehting that 5 in binary is 101(base 2) but I ran it through a binary prog and it came out as 00110101 and i was wondering why this is.
2.) Why is 0 as binary 00110000? is it just adding the 00110 to the original binary cause i also saw that 0 is just 000(base 2)
 |
|
| Author |
RE: Binary questions |
xtrmsk8r91
Member

Posts: 157
Location: /root
Joined: 16.10.05 Rank: Uber Elite |
|
1) you ran it through as a character string instead of an integer. so it (i think??) took the ascii value and converted that to binary, instead of the actual integer 5. 101 would be correct: 1(4) + 0(2) + 1(1) = 5.
2) again, the program accepted it as a character instead of an integer. 0 in binary is just 0.
hope that clears things up. binary can be kinda tricky, just read up on it (google) and you'll start to understand it.
|
|
| Author |
RE: Binary questions |
c4p_sl0ck
Member

Posts: 380
Location: Sweden
Joined: 17.09.06 Rank: God |
|
|
It seems to have taken the ASCII-value of 5 which is 53. |
|
| Author |
RE: Binary questions |
c4p_sl0ck
Member

Posts: 380
Location: Sweden
Joined: 17.09.06 Rank: God |
|
|
It seems to have taken the ASCII-value of 5 which is 53. |
|
| Author |
RE: Binary questions |
Happysmileman
Member
Posts: 347
Location:
Joined: 02.08.06 Rank: HBH Guru |
|
|
Basically its the last few numbers you need to look at... For example "A" is 01000001 while "a" is 01100001... The last few digits represent the position in the alphabet eg 1 for a... while the first few numbers are just there to group it... It's not all this easy but that's basically how it works. |
|
| Author |
RE: Binary questions |
Jake
Member
Posts: 107
Location: United States
Joined: 13.12.04 Rank: God |
|
Also, it gave you "00110101", because the most widely used form of binary is in base 8, which is what computers use. (2^8=256, 256 characters on the ASCII chart). And it converted the ASCII value of 5 to binary, not the number 5.
|
|
| Author |
RE: Binary questions |
Zekasu
Member
Posts: 171
Location:
Joined: 31.12.05 Rank: HBH Guru |
|
As per the numbers, it's probably running it through as an ASCII string, as mentioned earlier.
01000001 - A, int(65)
01100001 - a, int(97)
It's actually quite ingenious as to how the letters are arranged, in respect to electronics and logic circuits. All you have to do is switch a bit to change it from capital to lowercase, in ASCII. (Unicode's just a tad different, if I remember.) |
|