RE: ascii - math conversion
unsigned long l=100000;
That single lower-case letter 'L' makes this code really tough to read. It's extremely difficult to distinguish the lower-case letter 'L' from the numeric digit '1'. In some fonts, they're almost identical in appearance.
Aside from that, I think that there may be other problems with the two successive 'while' statements but I haven't thought through them in detail.
While it's always good to learn from one's mistakes, it's much easier to learn from the mistakes of others.
Please don't PM me with technical questions. I'll be quite happy to help (if I can) on the forums.