begin with, but now when it is it's not unreasonable that 0.0 should be false too.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-14 09:19: Subject: float type weirdness
Hi,
I was surprised that float type is somewhat "special", like here:
float x = 0.0; // OK, I can live with the fact that I just can't assign "0" :) // However, it would be convenient to make an exception for this // special case (zero)
if (!x) something(); // Will be never called, since x is _always_ true // while it is (numerically) is zero (7.4.20)
Is this intentional? According to the tutorial:
"When Pike encounters an if statement, it first calculates the value of the expression. Pike then checks if this value is true or false. The value zero (0) is considered to be false, and everything else is true."
It is not mantioned that "zero" has to be integer zero, and everywhere else (C, Perl etc) float zero is false.
Regards, /Al
/ Brevbäraren
pike-devel@lists.lysator.liu.se