Odd behavior comparing doubles, two PHP double values aren't equivalent
问题 I have two seemingly equal double values in PHP (at least when echoing them). But when comparing them with double equals, for some reason, it evaluates to false. Are there any special considerations when performing this kind of comparison? 回答1: You shouldn't compare floating point numbers using the == operator. See the big warning and explanation in the php manual What will work is asserting that the two numbers are within a certain small distance of each other like this: if(abs($a - $b) < 0