List Info

Thread: note 78069 added to language.types.float




note 78069 added to language.types.float
user name
2007-09-26 16:27:41
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.co
mparison.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  -- h
ttps://master.php.net/note/delete/78069/integrated
Del: useless     -- http
s://master.php.net/note/delete/78069/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/78069/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78069
Reject      -- https://mast
er.php.net/note/reject/78069
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


note 78069 deleted from language.types.float by bjori
user name
2007-09-27 07:31:13
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.co
mparison.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? 

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )