Simply want to compare a value of type Double to 0.

One Star

Simply want to compare a value of type Double to 0.

Bonjour,
I simply want to see if a value of type Double (row1.Debit) is superior to 0 in tMap.
(row1.Debit > new Integer(0).doubleValue()) ? "NWITHD" : "NDEP"
I've tried different angles (0.0, different functions) but I always get errors during run time.
What do I do wrong? What should I do to correct it?
Here's the log:
Starting job Conv_CP_CSV_to_QIF at 13:59 14/07/2009.
connecting to socket on port 4286
connected
Exception in component tMap_1
java.lang.NullPointerException
at sagarpa.conv_cp_csv_to_qif_0_1.Conv_CP_CSV_to_QIF.tFileInputDelimited_2Process(Conv_CP_CSV_to_QIF.java:1922)
at sagarpa.conv_cp_csv_to_qif_0_1.Conv_CP_CSV_to_QIF.runJobInTOS(Conv_CP_CSV_to_QIF.java:3098)
at sagarpa.conv_cp_csv_to_qif_0_1.Conv_CP_CSV_to_QIF.main(Conv_CP_CSV_to_QIF.java:3007)
disconnected
Job Conv_CP_CSV_to_QIF ended at 13:59 14/07/2009.

Thanks.
PM
Community Manager

Re: Simply want to compare a value of type Double to 0.

Hello PM
Your expression is right, but there are some null value in your Debit column, so you handle or filter the null row before referencing row1.Debit.
a) You can use a tfilterRow component to filter the null row.
b) or you define value as "NDEP" if Debit as null, eg:
row1.Debig==null?"NDEP": ((row1.Debit > new Integer(0).doubleValue()) ? "NWITHD" : "NDEP")
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Simply want to compare a value of type Double to 0.

Hello,
Shong is right, your test was ok, but sometimes the value must be null, so check it.
Just a note, you can write this kind of simplier test :
row1.Debit > 0d
Seventeen Stars

Re: Simply want to compare a value of type Double to 0.

hi all,
Hello,
Just a note, you can write this kind of simplier test :
row1.Debit > 0d


I was thinking at
row1.Debit >0.0d // default double value

I didn't know the "0d" could also be use Smiley Happy