Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Binary questions


ghost's Avatar
0 0

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)


ghost's Avatar
0 0
  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.


ghost's Avatar
0 0

It seems to have taken the ASCII-value of 5 which is 53.


ghost's Avatar
0 0

It seems to have taken the ASCII-value of 5 which is 53.


ghost's Avatar
0 0

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.


ghost's Avatar
0 0

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.


ghost's Avatar
0 0

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.)