0

I can't figure out why this simple math does not work. Maybe something about PHP and numbers I am not getting?

$step=1.0;

$step+=0.1;

$substep=$step-(int)$step;

echo gettype($substep);

echo $substep;

if ($substep==0.1) { 

    echo "should be here";

} else {

    echo "but I end up here";

}   

OUTPUT: double0.1but I end up here

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Corbin
  • 313
  • 1
  • 3
  • 11

0 Answers0