现在我有以下代码:
if ($costOne <> $costTwo) {}
我想将其更改为
if ($costOne is not within the range of $costTwo - .0001 and $costTwo + .0001) {}
我尝试过用几种不同的方式写这个,但我没有做正确的事情...... 有人可以为我提供正确的语法来表达这一点吗?
你基本上有它:
((($costTwo - 0.0001) <= $costOne) && ($costOne <= ($costTwo + 0.0001)))
或者,或者,或者
(abs($costOne - $costTwo) <= 0.0001)
你可以像下面这样做:
$lowerbounds = $costOne - .0001;
$higherbounds = $costOne + .0001;
if($costOne < $lowerbounds || $costOne > $higherbounds){ ....