0

I am having an issue with the floor function rounding 30.0 to 29.0 when dividing. I am trying to find a set percentage below a starting number.

        $goal = 33;
        $goalPercent = .1;  // Equals 10% for example
        $test1 = 33 / 1.1; // Try without variables
        $test2 = $goal / 1.1; // Try with goal variable
        $test3 = $goal / (1 + $goalPercent); //Try by making the percent

Instead of the result being 30.0 it is 29.0 even when using online compilers.

Austyn
  • 1
  • There was a change in floating point precision made in PHP 8, see here for details and how to revert the behavior: https://stackoverflow.com/a/69860831/1456201 – Jim Sep 15 '22 at 23:24

0 Answers0