PHP版本7.1.7 / Laravel 5.4
dump($this_tour->payments_to_operator_sum());
1012.0
dump(gettype($this_tour->payments_to_operator_sum()));
“双”
dump($this_tour->operator_price, gettype($this_tour->operator_price));
“ 1012.00”,“字符串”
dump((double)$this_tour->operator_price, gettype((double)$this_tour->opeartor_price);
1012.0,“双精度”
dump($this_tour->payments_to_operator_sum() == (double)$this_tour->operator_price);
false
为什么会是假的?
我很困惑。
PS。我了解“ ==”和“ ===”之间的区别,我想这与它无关。 当我这样做时:
dump((double)1012.0 == (double)"1012.00");
我得到
true
答案 0 :(得分:1)
当我这样做的时候:
return $this_tour->payments_to_operator_sum()
(而不是“ dump”),我得到了:
1011.9999999999999
所以我想这就是答案。