On his weblog today, Ilia Alshanetsky has some information about PHP and its support of floating point math - and an "interesting peculiarity" he found.
Came across a rather "interesting" peculiarity in PHP, which affects mathematical operations involving floating point numbers. The goal was to take an arbitrary floating point number and convert it to a whole number where decimal points became part of the whole.
In his efforts he discovered a piece of code that should have worked but created an unterminated loop - the problem being with the (as he puts it) "fudge when performing float math".
While we see float(123), internally we are actually working with 122.999999999999 or 123.000000000000001, these little seemingly insignificant decimal points make a world of difference. Their presence causes integer value which strips them to be slightly larger or smaller then the supposedly equivalent float, and leads to an unterminated loop.




