I'm afraid I won't have the time to look into your encryption formula.
I see that you're using file_asc_write, which excludes rounding errors by writing fractional numbers into the file. The fact that the difference is 64 should give you a hint, your algorithm seems to have a problem with bit #6.
If you know a critical number that is wrongly encrypted and decrypted, single step through your algorithm and check in which line the problem happens. Usual bugs in encryption algorithms are sign errors when a part of the number becomes negative. Debugging is faster when you don't write or read from a file, but just feed the output of your encrypter into the decrypter.