Here is a very simple code.
$a = 2000000.00000000;
$b = 0.00000001;
echo $a-$b; //output 2000000
I was expecting 1999999.99999999.
Can someone explain how to make it work ? It would be very appreciate.
Here is a very simple code.
$a = 2000000.00000000;
$b = 0.00000001;
echo $a-$b; //output 2000000
I was expecting 1999999.99999999.
Can someone explain how to make it work ? It would be very appreciate.
You can set the precision used when formatting floats as strings using the precision
ini setting, the default being 14:
ini_set('precision', 16);
echo $a - $b; // 1999999.99999999
Also, read this article for a more generic breakdown on the subject.