&&不在If()语句中工作[重复]

This question already has an answer here:

For some weird reason this if statement is not finding a match, when the values are clearly equal to the $change_pct_candle values as shown in var_dump below

if($change_pct_candle[1] >= 0.38022813688214 && $change_pct_candle[2] >= 1.3487475915221) {} 

If I try:

if($change_pct_candle[1] >= 0.38022813688214) {} 

It works. If I try:

if($change_pct_candle[2] >= 1.3487475915221) {}

It works. When I try:

if($change_pct_candle[1] >= 0 && $change_pct_candle[2] >= 1) {} 

It works. When I try:

if($change_pct_candle[1] >= 0.38022813688214 && $change_pct_candle[2] >= 1.3487475915221) {} 

It doesn't work. Am I doing something wrong here?

The var_dump of $change_pct_candle is:

array(7) {
  [0]=>
  float(-0.10984848484848)
  [1]=>
  float(0.38022813688214)
  [2]=>
  float(1.3487475915221)
  [3]=>
  float(-0.57471264367815)
  [4]=>
  float(0.19193857965451)
  [5]=>
  float(0.19230769230769)
  [6]=>
  float(0.1926782273603)
}
</div>

The reason is "Floating point numbers have limited precision". Just have a look at this page from php.net and pay close attention to the warning about this concept. That'll explain why , and hopefully what to do. http://php.net/manual/en/language.types.float.php

So never trust floating number results to the last digit, and do not compare floating point numbers directly for equality.