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