3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = 0.03; $b = 1 - 0.97; $c = (float)(string) 0.03; $d = (float)(string) (1 - 0.97); var_dump($a, $b, $a === $b, $c, $d, $c === $d); var_dump(sprintf('%1.18f', $b), sprintf('%1.18f', $d));
Output for 5.2.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
float(0.03) float(0.03) bool(false) float(0.03) float(0.03) bool(true) string(20) "0.030000000000000027" string(20) "0.029999999999999999"
Output for 4.3.0 - 5.2.0
float(0.03) float(0.03) bool(false) float(0.03) float(0.03) bool(true) string(20) "0.030000000000000027" string(20) "0.030000000000000000"