I have been pulling what little hair I have out for the past hour trying to figure out a very peculiar thing that was happening to me in php. I was doing some math and a function that I know was supposed to return 0 was returning 1.8189894035459E . If you called the function outside of a loop it worked fine, but is you called it in a while loop for instance, it would return this crazy value. All I had to do was to typecast the result of the integer addition to an (int) and the problem went away. Hope this might help someone in the future save some hair.