note 78069 deleted from language.types.float by bjori

From: Date: Thu, 27 Sep 2007 12:31:13 +0000
Subject: note 78069 deleted from language.types.float by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130846@lists.php.net to get a copy of this message
Note Submitter: jazz Reason: integrated ---- chrisgbk: My bet is that when rune said: >So if someone tells you that $a==$b implies $a===$b then you can tell them no, $a=$b=INF is a >counterexample. he actually meant: "If someone tells you that $a===$b implies $a==$b ..." It's never been true in PHP that the equality operator (==) implies the identity operator (===), but the reverse is usually true. See the definition of the identity operator at http://us2.php.net/manual/en/language.operators.comparison.php . Of course, this fails for INF (which is rune's point) because INF === INF is true but INF == INF is false (by your own argument). This makes a certain amount of sense. If I had some function that might return INF and I wanted to check to see if it had returned INF, I shouldn't use <?php if( mightBeInf() == INF ) doSomething(); //won't work! ?> because mathematically INF != INF. So in order to be able to check this properly, I need to use <?php if( mightBeInf() === INF ) doSomething(); //will work! ?> So assuming rune just mistyped that line, he's right.... $a = $b = INF is a counterexample to ($a === $b) -> ($a == $b). But for normal (non-boundary-case-flag) values of variables, that implication will hold. Everyone sick of this yet? ;-)

« previous php.notes (#130846) next »