-1

I was trying something and I ran into this problem:

<?php    
echo 100 - 99.9;
// gives: 0.099999999999994

can anyone tell me why this happened and how can I fix this?

1 Answers1

0

The reason for this is it's floating point number read why this happens here https://floating-point-gui.de/ more info is also avalible here https://www.php.net/manual/en/language.types.float.php TLDR: Floating point numbers have small difrenses at the end.

raketmus
  • 48
  • 6