Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Talend BigDecimal division output Weird

I have 2 BigDecimal Numbers. I am doing simple division: Number1/Number2. 

 

In talend: tMap: 80/8.52 = 9

but in excel: 

9.389671362

 

  The valid answer that I require is the Excel output. What the issue with BigDecimal division in Talend ?

0683p000009Lv4y.png

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Change the scale to 9 and add the rounding mode to the division, like in this example:

row59.num1.divide(row59.num2, 9, BigDecimal.ROUND_HALF_UP) 

The result is:

Starting job test at 18:01 23/05/2017.

[statistics] connecting to socket on port 3583
[statistics] connected
.----+----+-----------.
|     tLogRow_26      |
|=---+----+----------=|
|num1|num2|result     |
|=---+----+----------=|
|80.0|8.52|9.389671362|
'----+----+-----------'

[statistics] disconnected
Job test ended at 18:01 23/05/2017. [exit code=0]

Exactly what Excel gives you.

For this example, num1 and num2 are issued from a tFixedFlowInput:

0683p000009Lv0d.png

And the result is computed in a tMap:

0683p000009Lv53.png

Hope this helps.

View solution in original post

2 Replies
TRF
Champion II
Champion II

Change the scale to 9 and add the rounding mode to the division, like in this example:

row59.num1.divide(row59.num2, 9, BigDecimal.ROUND_HALF_UP) 

The result is:

Starting job test at 18:01 23/05/2017.

[statistics] connecting to socket on port 3583
[statistics] connected
.----+----+-----------.
|     tLogRow_26      |
|=---+----+----------=|
|num1|num2|result     |
|=---+----+----------=|
|80.0|8.52|9.389671362|
'----+----+-----------'

[statistics] disconnected
Job test ended at 18:01 23/05/2017. [exit code=0]

Exactly what Excel gives you.

For this example, num1 and num2 are issued from a tFixedFlowInput:

0683p000009Lv0d.png

And the result is computed in a tMap:

0683p000009Lv53.png

Hope this helps.

Anonymous
Not applicable
Author

Thanks a lot for your prompt help !!! It worked.