Hi Joe,
Due to a bug in sprintf replacing the if statement solves the problem:
Thanks for the new patch, it seems to work well for me! And I don't think there's a bug in sprintf(), it's just a known problem that PHP (and other languages like Python) don't deliver proper math results by default when dealing with base 10 floating point numbers. The real fix would be to use something like BC Math here which is slower (not enough to matter for this purpose) but delivers correct results all the time. We ended up using BC Math for some of our custom FA reports because otherwise it's really flakey to do math on floats and then try to do an equality comparison with 0.0, for example. Because the result of your floating point math will actually be something like 0.00000000000001239458345 if you printf() it with enough digits to see that. Annoying!
-Jason