I have tested this in PHP 7.4.33 and 5.6.4
I have a specific calculation in some code and it’s worked until a very specific set of numbers was thrown at it: 103.80 – (20 * 5.19)
This should be 0, but it seems PHP thinks that 103.80 – (20 * 5.19) = -1.4210854715202E-14
If I change any digit in the formula, the calculation is correct.
Examples:
103.60-(20×5.18) = 0
103.80-(20×5.18) = 0.2
and any thing else works…except
103.80-(20*5.19) = -1.4210854715202E-14
Try it yourselves and let me know what you get:
`<?php
echo 103.80-(20*5.19);
?>`
Howard Jackson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.