Float data type issue

One Star

Float data type issue

Hi,
I have column with the datatype float(8,6), in the initial load the value it takes as 1.299999 and in the second run it gives the values as 1.299998. What could be the issue behind this inconsistency.This causes our insert update stratergy to fail.
One Star

Re: Float data type issue

In Source database the value is 1.3 but Talend is reading it as 1.299999 which seems to be a bug. Any idea how this could be handled.
Seventeen Stars

Re: Float data type issue

hi,
you have to use BigDecimal to keep all precision on decimal.
Float & Double in Java could round number.
http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html
regards
laurent
One Star

Re: Float data type issue

Hi,
After using data type as bigdecimal,Talend won't allow to perform *,/ oprations and abs() function on that column.
Please help me on this.
One Star

Re: Float data type issue

Hi you can use code like
  row1.nb.compareTo(new BigDecimal("0"))<=0?row1.nb.multiply(new BigDecimal("-1")):row1.nb

to replace abs()
Seven Stars

Re: Float data type issue

row.column1.abs()
row.column1.multiply(row.column2)
row.column1.divide(row.column2)
See the Java docs.