Hi everybody,
sorry this is a greenhand's stupid question. Why isn't "0.0" false? I
know it is a string but I still think it equals to 0.
Thanks ahead, green green~~
2008/11/17 Ting Chen gilltdr1008@gmail.com:
Hi everybody,
sorry this is a greenhand's stupid question. Why isn't "0.0" false? I
know it is a string but I still think it equals to 0.
I think you answered your own question there.
Andrew
i am recently studying Php5 manul. This is one of the examinations in
the book. The answer is "0.0" is true rather than false. I am very
curious about why if the answer is not wrong.
green geen still green~
2008/11/17 Ting Chen gilltdr1008@gmail.com:
Hi everybody,
sorry this is a greenhand's stupid question. Why isn't "0.0" false? I
know it is a string but I still think it equals to 0.I think you answered your own question there.
Andrew
maybe because "0" evaluating to false is already enough and everything
after that would be "forcing" too much. If "0.0" evaluates to false
then I would ask, why "0.0E1" doesn't ? What about "0.0E2" ? "0.0E10"
? etc. Just my opinion.
regards,
Igor.
i am recently studying Php5 manul. This is one of the examinations in
the book. The answer is "0.0" is true rather than false. I am very
curious about why if the answer is not wrong.
thanks for answering my question,
green, green, I am so green
maybe because "0" evaluating to false is already enough and everything
after that would be "forcing" too much. If "0.0" evaluates to false
then I would ask, why "0.0E1" doesn't ? What about "0.0E2" ? "0.0E10"
? etc. Just my opinion.regards,
Igor.
i am recently studying Php5 manul. This is one of the examinations in
the book. The answer is "0.0" is true rather than false. I am very
curious about why if the answer is not wrong.
Andrew Rose wrote:
2008/11/17 Ting Chen gilltdr1008@gmail.com:
Hi everybody,
sorry this is a greenhand's stupid question. Why isn't "0.0" false? I
know it is a string but I still think it equals to 0.I think you answered your own question there.
Andrew
What he means is that == is not transitive. That is,
"0" == false
"0" == "0.0"
But
false != "0.0"
The answer to "why" is, well, that's the way it is. "0.0" just "looks"
too much like a string, maybe, to be made into a boolean. You can just
cast it into int like (int) "0.0" to make it work, however.
Federico Lebron