RE: [PHP] Is this a bug?

From: Date: Mon, 20 Aug 2001 21:16:57 +0000
Subject: RE: [PHP] Is this a bug?
Groups: php.general 
Request: Send a blank email to php-general+get-63568@lists.php.net to get a copy of this message
> -----Original Message----- > From: Ratko [mailto:ratko@email.si] > Sent: Monday, August 20, 2001 1:40 PM > To: php-general@lists.php.net > Subject: [PHP] Is this a bug? > > > Please try this: > <? > echo "996448234192168122"=="996448234192168125"; > ?> > > I get "true" as a result. How's that possible? > But if I do: > echo "996448234192168122"==="996448234192168125"; > then I get "false" as expected. A couple of snippets from the PHP manual: http://www.php.net/manual/en/language.types.integer.php: "The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed)...If you specify a number beyond the bounds of the integer type, it will be interpreted as a float instead" ...and... http://www.php.net/manual/en/language.types.float.php "The size of a float is platform-dependent, although a maximum of ~1.8e308 with a precision of roughly 14 decimal digits is a common value...Never trust floating number results to the last digit, and never compare floating point numbers for equality. If you really need higher precision, you should use the arbitrary precision math functions or gmp functions instead." --- Mark Roedel | "Blessed is he who has learned to laugh Systems Programmer | at himself, for he shall never cease LeTourneau University | to be entertained." Longview, Texas, USA | -- John Powell

« previous php.general (#63568) next »