Double datatype, Rounding and Precision problems

One Star

Double datatype, Rounding and Precision problems

I have 2 fields in my project that are set as Double 5,2. They're used to store a result from a calculation using rates and minutes. The corresponding fields in the mysql database are set as Double 6,3. Somehow, even though the precision is set to 2 inside the project, there are 3 significant digits being stored in the database. How is it going from 5,2 in the project to 6,3 in the database? Shouldn't it be truncating a digit when it exports?
Secondly, if I change to Decimal 6,2 in my tMap component and mysql fields, will it properly store the rounded number? I'm thinking I need to be using 6,3 in the calculations since the rates go out to 3 significant digits (ex. .437).
My goal is to end up with a currency value but using mysql means decimal is my closest option.
One Star

Re: Double datatype, Rounding and Precision problems

I looked a little closer and see that in the mysql mapping file in the preferences that Double is defaulted to 20,10.
Could it be ignoring my precision and going with the default? That would explain how the 3 decimal places are making
it to the database even though my tMap and schema are set at 5,2.
One Star

Re: Double datatype, Rounding and Precision problems

Maybe it ignores the specified precision until it's larger than the default one? In other words, maybe it knows that anything 5,2 will fit into 20,10 so it's not trying to round the decimal places to 2?
What would happen if I left it like this and changed the mysql fields to decimal 6,2? would mysql try to round it or would Talend attempt it first?