NYCPHP Meetup

NYPHP.org

[nycphp-talk] Unfriendly Float Handling

Adam Maccabee Trachtenberg adam at trachtenberg.com
Fri Mar 31 18:22:55 EST 2006


On Fri, 31 Mar 2006, tedd wrote:

> if ($a < $b + .01 && $a > $b - .01)

I've found for me a more clear way to do this is:

define('epsilon', 0.01);

if (abs($a - $b) < epsilon) {

But I don't feel strongly about it. :)

-adam

-- 
adam at trachtenberg.com | http://www.trachtenberg.com
author of o'reilly's "upgrading to php 5" and "php cookbook"
avoid the holiday rush, buy your copies today!



More information about the talk mailing list