Click to See Complete Forum and Search --> : How did you memorize binary characters?


SonOfAres
01-24-2003, 12:06 AM
Thanks to the good people at my other post, I found an ASCII table with the listings for alphabetical characters in binary. I could just carry a list around, but that's cheating.... so how did you guys memorize the string of 1's and 0's? do you guys just go to a webpage everytime u wanna use them or what?

nouse66
01-24-2003, 12:20 AM
why would anyone want to memorize an ascii table? that just doest make sense to me...

BigFatJoe
01-24-2003, 12:29 AM
Originally posted by nouse66
why would anyone want to memorize an ascii table? that just doest make sense to me...

oh cmon!
weren't YOU ever stuck in traffic, and had a fairy come up to tell you if you could recite the ascii table backwards in binary she'd set you free....
:D

^wow, thats really wierd. even by my standards.

carrja99
01-24-2003, 01:12 AM
ROFL!

I agree... I'm a programmer and code very often... I see little reason for memorizing binary values of characters. But, sigh, I will go ahead and give you a method I assume you could use.

I suppose you could just remember what A's decimal value is. Then you could just count to the letter you need. Then take the decimal value and reduce it to base-2 representation, aka binary.

EDIT: oh! For the mathematically inclined, I will include how to find a binary value. Basically, you find it by dividing by 2 until you get 0... it's easier for me to just show it:

For example, to conver 19 to binary...
19/2 = 9 R 1
9/2 = 4 R 1
4/2 = 2 R 0
2/2 = 1 R 0
1/2 = 0 R 1

So, 19 is represented in binary as 10011. just read the remainders backwards.

timbobagginsii
01-24-2003, 04:00 AM
Originally posted by BigFatJoe
oh cmon!
weren't YOU ever stuck in traffic, and had a fairy come up to tell you if you could recite the ascii table backwards in binary she'd set you free....
:D

^wow, thats really wierd. even by my standards.
This coming from someone that doesn't drink or do drugs??

Nugget
01-24-2003, 05:41 AM
101001 10111010110 110101 100100101 1001010 100101 00101010 10101 10010101 1010101 1001010 1

bwkaz
01-24-2003, 11:10 AM
'A' == 65, since the 6th bit (64) is on for all uppercase characters, and 'A' is the first of these.

'a' == 97, because the 6th and 5th bits (64 + 32 == 96) are on for all lowercase characters, and 'a' is the first of these.

Numbers start with '0' == 48 (48 for 16 and 32, the 4th and 5th bits)

Space is 32, quote is 34, and I only know those because they were important back in BASIC where you couldn't escape the quote character. So if you wanted to print a quote, you had to print chr$(34). Space just sort of caught on, I'm not sure why.

Anything above 127 is nonstandard, differing from character set to character set.

And that's all I know. Most of it came from looking at patterns on an ASCII chart.

hecresper
01-24-2003, 02:06 PM
wholly cow! this is some cool stuff!

Off to learn this I go!!!

I like Carrja's method. It simple to understand even for people like me who hate Math. I think that's why I never got into programming. hmm? :)

hecresper
01-24-2003, 02:22 PM
Found this:

ASCII to Binary conversion (http://nickciske.com/tools/binary.php)

wapcaplet
01-24-2003, 02:28 PM
One cool thing I remember from a compiler-design course I took is that the digits ('0' through '9') in ASCII all begin with the hex digit 3. To get an integer value back out of ASCII for the digits, just subtract hex 0x30.

i.e., 0x30 -> 0 decimal, 0x35 -> 5 decimal.

Though, most of the time for programming you don't even need to know that, since you can just do manipulations using the literal ASCII character. Like, to see if a character is an uppercase letter, say:

if (c >= 'A' && c <= 'Z') ...

For the curious, it's a lot easier to convert from binary (base-2) to hexadecimal (base-16) and vice versa, than it is to convert either one into decimal (base-10), since each hexadecimal character is equivalent to exactly four binary digits. So:

0x1 = 0001
0x2 = 0010
0x3 = 0011
...
0xA = 1010
0xB = 1011
0xC = 1100
0xD = 1101
0xE = 1110
0xF = 1111

So if you see binary: 0010 1110, you know it's the same as hex 0x2E. If you see hex 0xF5, you know it's 1111 0101 binary. Pretty cool huh?

Well, maybe not. But it explains why you see hexadecimal all over the place in low-level computer code.

hecresper
01-24-2003, 02:31 PM
01010100010010000100010101001101010000010101010001 01001001001001010110000100100001000001010100110101 10010100111101010101 = THEMATRIXHASYOU

Too Cool!

carrja99
01-24-2003, 02:47 PM
Yeah? Wait until you get into binary mathematics, with different representations (un-biased, biased, 1's comp, 2's comp, etc) and the different functions performed on binary numbers such as aritmatic shifts and logical shifts, not discounting rotations, and then finally being assigned to write a program to convert any base to another base as well as do number multiplication without using any C/C++ operators (such as + or *) ... you may not think it is so cool.

Of ocurse, I look back and laugh at the idea I stayed up all night baffled on these subjects and now I can write the above program on a piece of paper and it's perfectly error free! :D

wapcaplet
01-24-2003, 04:29 PM
Originally posted by carrja99
Yeah? Wait until you get into binary mathematics, with different representations (un-biased, biased, 1's comp, 2's comp, etc) and the different functions performed on binary numbers such as aritmatic shifts and logical shifts, not discounting rotations, and then finally being assigned to write a program to convert any base to another base as well as do number multiplication without using any C/C++ operators (such as + or *) ... you may not think it is so cool.

Oh, I've been through all that. Several times. I still think it's pretty cool :)

Of ocurse, I look back and laugh at the idea I stayed up all night baffled on these subjects and now I can write the above program on a piece of paper and it's perfectly error free! :D

I'm not sure I would bold enough to make claims about error-free programs. Though, last semester I was working on a programming project of a couple thousand lines, and a couple dozen C++ and header files. After a couple hours of editing, I said "hey, let's compile and see how many errors we get" and was shocked that there were none! That does not happen often. (though of course, there were still a few run-time errors)

carrja99
01-24-2003, 05:10 PM
bleh, my errors are usually typos, such as using a : instead of a ;

btw, I was tutoring someone the other night, and they used "void main()"... why in the world do people use void main() instead of just using main()!? Dunno why, but it gets on my nerves! As a tutor this semester, I have ran across it quite often.

Anyway, just for fun:

#include <iostream.h>

main()
{
float *p;

for(int i = 0; i > -1; i++)
{
p++;
p = new float;
*p = i*i*i*i;
cout << p << " " << *p << endl;
if (((i*i)%2)==0)
p-20;
}

return 0;
}



Ok... don't ask why... for some reason I felt like unleashing such a terrible piece of code! :D

Dun'kalis
01-24-2003, 06:45 PM
Most people were taught to use void main(). I was taught that initially, but I now use int main().

Oh, and you may want to change that iostream.h to iostream and add:

using std::cout;
using std::endl;

But, whats the point of that? I'm not getting it...

wapcaplet
01-24-2003, 07:08 PM
Originally posted by carrja99
why in the world do people use void main() instead of just using main()!? Dunno why, but it gets on my nerves!

Some people might've been taught that way. Others might have tried just main(), but then got confused when they forgot to put a return somewhere, and decided to make it void so it wouldn't need a return.

Just using main() kind of assumes that the compiler will give it a default type (usually int, but maybe not) - so it's always clearer to put *something* as the return type, at least. Explicitly using int is probably a good idea.

BigFatJoe
01-24-2003, 08:18 PM
Originally posted by timbobagginsii
This coming from someone that doesn't drink or do drugs??

I don't use drugs, my dreams are frightening enough.
(Marie E. Eschenbach)
:D

Wouldn't putting main() make the compiler insert something? Keep clean code, dont make the compiler assume. I usually mention int for a return.

carrja99
01-24-2003, 08:19 PM
Sometimes I use int, sometimes I don't. Still, I just dont understand why someone would use void...

Arcane_Disciple
01-24-2003, 09:01 PM
I was taught to only use void if your main() contains only a menu and function calls.