Click to See Complete Forum and Search --> : ASCII characters


thmnetwork
01-08-2004, 04:57 PM
the addition program from my "segmentation fault" thread works now. The only problem is it says 2 + 2 is lowercase d. I'm taking a shot in the dark, but I'd say it's puling that off of the ASCII chart.

I tried ANDing it with F, but that left me with a blank for what was returned.

Posting this in a new thread cause I think I read somewhere that you have to post different problems to different threads.

Source code included (I cleaned up the source a little, hope it's a little easier to read.)

jim mcnamara
01-08-2004, 05:19 PM
It's ctrl-D ^D ASCII 4

thmnetwork
01-08-2004, 05:55 PM
yeah I got to looking, 64 is lower case d. For some reason it seems to be starting at 60, 1 + 0 is a 1+1 is b etc

bwkaz
01-08-2004, 08:43 PM
The ASCII code for the character '1' is 33. The ASCII code for the character '0' is 32.

The ASCII code for uppercase 'A' is 65 (which is '1' + '0').

Your example of '2' + '2' (which is 34 + 34) results in 68, which is 'D'.

You need to subtract 32 from the numbers before you add them together, then add 32 when you're done. And hope that your addition doesn't overflow one digit, or you won't get a number printed when you're done.

thmnetwork
01-09-2004, 12:12 AM
it was actually 48 not 32, but yeah it works now thanks.

bwkaz
01-09-2004, 07:40 PM
48?

Ohh, right, duh. 48+49 is 97, which is lowercase 'a'.