note 78069 added to language.types.float

From: Date: Wed, 26 Sep 2007 21:27:41 +0000
Subject: note 78069 added to language.types.float
Groups: php.notes 
Request: Send a blank email to php-notes+get-130809@lists.php.net to get a copy of this message
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? ;-) ---- Server IP: 64.71.164.2 Probable Submitter: 163.191.24.14 ---- Manual Page -- http://www.php.net/manual/en/language.types.float.php Edit -- https://master.php.net/note/edit/78069 Del: integrated -- https://master.php.net/note/delete/78069/integrated Del: useless -- https://master.php.net/note/delete/78069/useless Del: bad code -- https://master.php.net/note/delete/78069/bad+code Del: spam -- https://master.php.net/note/delete/78069/spam Del: non-english -- https://master.php.net/note/delete/78069/non-english Del: in docs -- https://master.php.net/note/delete/78069/in+docs Del: other reasons-- https://master.php.net/note/delete/78069 Reject -- https://master.php.net/note/reject/78069 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130809) next »