I didn't read everything, but I see floating point numbers, and I see comparisons.
Perhaps you're not aware of the "approximation" factor in floating point numbers, where apparently obvious things like (2 / 0.1) == 20 are not necessarily true.
I'll keep reading the thread to see if it's something else, but I'd put a bet on this one.