Camilo Sperberg - 2012-10-14 16:46:15 - In reply to message 3 from chaitanya
I've looked over this issue and the problem isn't resolvable from the class without it knowing first what the table definition is.
You see, float is an INEXACT data type in MySQL (1) and because of this, the exact value stored by MySQL isn't 0.01, but differs slightly to 0.009999999776482582, which is what the class receives and also displays. When you format it with printf or any other function, they will round the value.
The solution to this is to use an exact data type, such as decimal (2), MySQL will store this exactly as you say to store it, so that you don't get this type of problems.
As I say, I see no way of casting the data type without knowing before what type of data we are dealing with, which will imply another query to get the data type of the implied tabled and parsing them, which will add a lot of overhead and make everything much slower.
In (3) I've added a screenshot when your same table is using decimal instead of float as data type.