Re: PHP can't compare...

From: Date: Tue, 04 Dec 2001 22:28:28 +0000
Subject: Re: PHP can't compare...
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-72522@lists.php.net to get a copy of this message
On Tue, 4 Dec 2001 23:05:04 +0100 (CET) Derick Rethans <d.rethans@jdimedia.nl> wrote: > Hello, > > this is how floating point numbers work. > > 3.55 as float is not 'exactly' 3.55, but it is stored in memory as an as > good as possible representation, something like 3.55000000001 perhaps. > > If you simply compare this: > 3.55000000000001 + 60.12000000000000001 != 63.66666666666669 And as far I can remember, never compare non "ordinal" (1,2,3 is) value. Whatever langage you use, binary egality test on float is very dangerous. hth pa -- Pierre-Alain Joye Freelance Developpements et Services web/intranet pajoye@tuxfamily.org

« previous php.dev (#72522) next »