I am using PDO to execute Stored Procedures on an MSSQL database. Everything works absolutely brilliantly apart from one small hitch with PDOStatement::fetchAll()
. When returning floats from the Stored Procedure, instead of returning them with the correct value and decimal place, it is returning the value with extra decimal places like so:
Database | Returned by PDO
-----------------------------------
614.9 | 614.89999999999998
1.18 | 1.1799999999999999
It seems as if there are rounding issues... I don't understand why it is trying to round the number anyway, surely it should just take the value from the database as it appears?
I have tried:
- Running the Stored Procedure on the DB and this works absolutely fine, therefore it is definitely something to do with PDO.
- Running a normal query (instead of a Stored Procedure), and this still produces the same result.
Obviously I can format the number myself, but this is irrelevant as I have to be sure that what I get from the database is exactly what is in the database!