Re: Simple math failing - PHP Bug?

From: Date: Mon, 01 Nov 2004 06:06:39 +0000
Subject: Re: Simple math failing - PHP Bug?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200810@lists.php.net to get a copy of this message
--- "Brian T. Allen" <brian@gzmarketing.com> wrote: > Well, in fairness, it's one of the worst ideas you've ever heard > because you know of this limitation. Of course. That wasn't a dig at you or anything - just a comment. You're free to heed or ignore it. > In reality, using a calculator or something that doesn't share > this limitation, 0 = 0 and this wouldn't be a problem. Well, 0 == 0 in PHP, too. Calculators have the same limitations that any other computing device does. Some modern calculators have some pretty impressive precision, but it's not hard to exceed it with a few seemingly harmless operations. A couple of numbers like 12.34567 and 23.45678 can get pretty nasty with a few operations. Regardless of this, I'm not in favor of depending on anything that's the least bit questionable or complicated. I don't even like evaluating integers as boolean unless they are strictly 0 or 1, and even then there can be problems (you accidentally decrement a variable twice before evaluating it again, so that it goes from 1 to -1 and continues to evaluate as true forever). In short, complexity breeds problems, regardless of how smart you are. Chris ===== Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly HTTP Developer's Handbook - Sams Coming January 2005 http://httphandbook.org/

« previous php.general (#200810) next »