Floor rounding gives the incorrect value when dividing numbers and I can't figure out why

Viewed 18

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.

0 Answers
Related