floor() in PHP returns wrong answer

Viewed 164

This is probably one of the weirdest cases I've ever seen in debugging in PHP. This is a very simple sum: 104.85 / 34.95. The answer is 3 (use your calculator if you don't believe me ).

PHP returns a float(3), but when I use the function floor() on the sum, so floor(104.85 / 34.95), it returns a float(2). I know floats can be tricky sometimes, but I have no idea how this is possible and how I could solve this. I need the floor() functionality for my application. So if anyone has an alternative, answers are welcome.

Update: My current PHP version is 7.2.9

0 Answers
Related