The problem is that the number is converted to a float first, and precision is lost. I'm afraid you'll need to try a different algorithm.