getChangedRecordData precision error?

If after a scripted record update I check the databaseManager.getChangedRecordData() for discover the number of update I get this for unchanged records:

(Object) BufferedDataSet{[mc,7.630000114440918,7.63][peso,186.94000244140625,186.94][ferro,155.50999450683594,155.51][trefolo,488.7699890136719,488.77][rete,181.27000427246094,181.27][mc_cls,7.630000114440918,7.63]}

The backend DB is a MYSQL 5.0.45 with JDBC driver version 5.0.8 and all these fields are FLOAT

Servoy 4.0.1
JDK 1.6.0_10

FLOATs columns are tricky, are you sure you really need to use FLOATs?
Usually the problem arises when you store decimal numbers in floats fields, Servoy writes 186.94 to the DB and the DB saves in the floating column 186.94000244140625, then Servoy thinks that there is unsaved data because the two values are different. Why you don’t just use a DECIMAL(10,2) column?

Thanks Nicola. I solve with this trick.

You’re welcome but this is not a trick, FLOATs should only be used when you need to store values with an undetermined number of decimals, basically for mathematic or geometric applications, I’ve never found the need to use them for any commercial application I’ve been working on. As a rule of thumb I think it’s always a good practice to round numeric values before writing them to the DB to prevent unexpected results. If you define a rounding strategy at least you define the precison level of your application by design, using FLOATs to handle rounding could lead you to unexpected results and to the inability of knowing the application precision level.

could lead you to unexpected results

And get you into trouble, hours of hours spent on debugging without knowing where to look…

you guys are right! but…
if you create the column in Servoy with type Number, it will become standard a FLOAT! :roll:

Harjo:
you guys are right! but…
if you create the column in Servoy with type Number, it will become standard a FLOAT! :roll:

Not exactly, with MySQL if you create the column in Servoy as Number AND you don’t specify the lenght it will become a FLOAT (I also had my share of pain with this :) ).
You need to be sure to set the number of decimals you want in the lenght of the field.

Ah oke, that I did’nt know.

Thanks for replying that. :-)

just to be sure, what do you fill in, if you need to store currency, with two decimals?

Yes, 2 decimals and I always round it before saving if there have been any * or /