Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to devide a BigDecimal value...

Hi *,
using tMap, I'm trying to devide a BigDecimal vaule by 100. Pretty simple, I thought.
Source and target fields are BigDecimal, but by using the following syntax I get an error like: "Exception in component tRowGenerator_1" by clicking the 'Test'-Button in the expression editor of the target field.
new BigDecimal(100).divide(row1.theUltimateValueWhoNeedsToGetDevidedBySomething)

What is the mistake?
Thank you!
Ben
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hey Lijo,
thank you for your help! You pushed me into the right direction!
I found a second problem in my syntax: I muddled up the source value and the division value; for example:
100 divided by 15 (false)
instead of
15 divided by 100 (correct)

So the code is now working, I just needed to swap those values in the code, thanks again!
row4.MWST_SATZ.divide(new BigDecimal(100),java.math.MathContext.DECIMAL32)

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Here is the error I get by running the job:
no exact representable decimal result.
at java.math.BigDecimal.divide(Unknown Source)
Anonymous
Not applicable
Author

Is nobody able to help me out on this issue?
Anonymous
Not applicable
Author

Hi
use
new BigDecimal(100).divide(row1.theUltimateValueWhoNeedsToGetDevidedBySomething,RoundingMode.HALF_UP)
Anonymous
Not applicable
Author

Thank you!
But now Talend is telling me that 'RoundingMode' cannot get resolved... Would it be better to change the data type into double or something like that?
Anonymous
Not applicable
Author

Hi
Sorry i didnt give fully
write java.math.RoundingMode.HALF_UP instead of RoundingMode.HALF_UP
Anonymous
Not applicable
Author

Hey Lijo,
thank you for your help! You pushed me into the right direction!
I found a second problem in my syntax: I muddled up the source value and the division value; for example:
100 divided by 15 (false)
instead of
15 divided by 100 (correct)

So the code is now working, I just needed to swap those values in the code, thanks again!
row4.MWST_SATZ.divide(new BigDecimal(100),java.math.MathContext.DECIMAL32)