[resolved] Substraction between 2 Big Decimal values
Hi All I am struggling with a Mathematical operation in tMap. I have a need to subtract 2 Big Decimal values and convert the output to string. Can someone please help me on how to achieve this? Thanks Kalyan
try this... and note that the below is based on your wanting to subtract one big decimal value from another. For the sake of making your coding cleaner you can break your equation (in tMap) into a couple of steps to assign values to be used by the above listed statement. 1) digDecimalValue will be the result of ... row3.ATTRIB_24.multiply(row3.ATTRIB_14).divide(BigDecimal.valueOf(100.00)) 2) String bigDecimalString = row3.ATTRIB_24.subtract(bigDecimalValue).toString(); Hopefully the above is what you are looking for.
Hi Kalyan, Would be interested in as to what all approaches did you try with? & was it the 'subtracting' part or the 'converting' part that really posed the challenge? MathurM
Hi Mathur, I tried the following and i get the error as below: (row3.ATTRIB_24 -(row3.ATTRIB_24.multiply(row3.ATTRIB_14).divide(BigDecimal.valueOf(100.00)))) The operator - is undefined for the argument type(s) java.math.BigDecimal, java.math.BigDecimal
try this... and note that the below is based on your wanting to subtract one big decimal value from another. For the sake of making your coding cleaner you can break your equation (in tMap) into a couple of steps to assign values to be used by the above listed statement. 1) digDecimalValue will be the result of ... row3.ATTRIB_24.multiply(row3.ATTRIB_14).divide(BigDecimal.valueOf(100.00)) 2) String bigDecimalString = row3.ATTRIB_24.subtract(bigDecimalValue).toString(); Hopefully the above is what you are looking for.