Re: PHP can't compare...

From: Date: Tue, 04 Dec 2001 22:54:52 +0000
Subject: Re: PHP can't compare...
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-72525@lists.php.net to get a copy of this message
> However, even if the number is not stored as indicated, ie. 3.55000000001 > instead of a clean 3.550000000, then why does PHP take the liberty to chop > off that precision when converting to a string? And why is that precision > not put back on when going back to a double? It is not put back on because > PHP can represent 3.55 as a clean 3.5500000000, so the assignment of > floats, ie. $fFloat = 3.55;, is coded in error in PHP's internals!? PHP is not the only langage with this kind of "problem", try js, pascal and so on. I don't know what people learn actually in computer langages courses, but one fact is, NEVER make binary test on non ordinal data. > I'm going to stop ranting and go check PHP's source, make some tests in C > and such. But with this type of number representation, PHP becomes > inaccurate in all but the most simple use of numbers. Maybe work with bcmath. Normally it does not have common precision errors. -- Pierre-Alain Joye Freelance Developpements et Services web/intranet pajoye@tuxfamily.org

« previous php.dev (#72525) next »