I have some calculations on the client side with JavaScript.
var total = (((3 * 24) / 100) + 3); //result is 3.7199999999999998
I need to store this 3.7199999999999998
number in the database as it is.
Database is on MySQL, i use Doctrine 2 for ORM, and entity has the precision set to /** @Column(type="decimal", precision=32, scale=16, nullable=false) * */
, but after saving i see that in database is just the number 3.72
, wtf ? After some checking i found that doctrine uses floatval
and after executing this floatval(3.7199999999999998)
you get 3.72
!! why?
Is there a workaround for this ? like telling doctrine not to use the floatval and store the value as it is? also i dont want to use varchar for this column.
Thanks in advance!