Talend BigDecimal division output Weird

Five Stars

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 ?

post.PNG


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Talend BigDecimal division output Weird

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:

Capture.PNG

And the result is computed in a tMap:

Capture.PNG

Hope this helps.


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: Talend BigDecimal division output Weird

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:

Capture.PNG

And the result is computed in a tMap:

Capture.PNG

Hope this helps.


TRF
Five Stars

Re: Talend BigDecimal division output Weird

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

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads