I upgraded some accounting scripts to PHP 8.1 however I am getting incorrect floating points.
I loop a few transactions debit/credit and the balance is 0 however at the end when I try to compare to zero its not working with == 0 and === 0
After a few debugging I found out:
<?php
var_dump(1097.5 - 835.7);
returns float(261.79999999999995)
And the same line in PHP 7 returns float(261.8)
This can easily be tested using this sandbox
So I was wondering is there any settings I can change in my PHP configs to make sure I get the same floating results has before without having to go and round up at every stage in hundreds of scripts?