# Can't figure out how to fix my equation

I've been banging my head trying to figure out why my ciphertext ends up ciphering by a completely different number, and including non-alpha characters.

My cipher code is as follows, with ASAL being 71 and ASAU being 65 ``` ~/workspace/pset2_test/caesar/ \$ ./caesar7 15 plaintext: haiLey paTrick ciphertext: ]V^AZT KVIM^X ``` I tried a key of 15 and in the example below, the key is -5, and somehow that translated to a shift of -11 along the ascii table. ``` ~/workspace/pset2_test/caesar/ \$ ./caesar 15 plaintext: haiLey paTrick ciphertext: ]V^AZT KVIM^X ```

If I take the first letter, "h", that should come out as 'w" in the ciphertext. I tried calculating the equation by hand, and I got this:

With the %26, I get ((104-71)+15)%26+71=112.
Without %26, I get ((104-71)+15)+71=119, the ascii code for lowercase w.

Obviously, something is wrong here, but I have no idea what it could be. Any help would be greatly appreciated.

Why `71`? `'a'` is an 8-bit integer with decimal representation of `97`.
``````((104-97)+15)%26+97
For upper-case letters, it would be `'A'` or `65`. Since in C, characters are integers, you could even use letters in the formula, like `(input_letter-'A'+key)%26+'A'`.