On MySQL 8.0.21, I have an empty table (Tbl) with a single column: num, of type float.
I insert a single line, with the value 0.1:
INSERT INTO Tbl(num) VALUES(0.1)
I run the following query and get the expected value 0.1:
SELECT MAX(num) FROM Tbl
Now, I run a query which I think is semantically equivalent to the first query, and get 0.10000000149011612:
SELECT MAX(IF(TRUE, num, 0)) FROM Tbl
Interestingly, this behavior doesn't reproduce without MAX, i.e. the following returns 0.1:
SELECT IF(TRUE, num, 0) FROM Tbl
I know that floating point numbers cannot always be represented accurately, and I understand why arithmetic operations can cause this sort of issue, but why should using this IF inside MAX make a difference?