Mark Rogers wrote:
I assume this is because $x isn't really 1.605, but something very close to (and slightly below) 1.605 due to a rounding issue, so rounding to 2 decimal places causes it to round down not up. But I'm not sure how to change the code to give the correct results?
Something I have found that works here is: round( round($x, 3) , 2) .. which forces the value to "round" to 1.605 then to 1.61, but I'm not sure if this would be a general solution (I'm guessing there are values of $x this would fail for, and maybe even values of $x where round($x,2) would be right but the 2-stage rounding would be wrong).