I have a source data file (dataset) that has a column defined as varchar(17). The column contains decimal values (11 places after decimal). Example:
0.28765498765
1.98198765200
1936.27000000000
I want to sum up column values but without any rounding. Example below....
Example: A
1936.27000000000
1432.12340000000
----------------------
3368.39340000000
Example: B
0.28765498765
1.98198765200
----------------------
2.26964263965
I am not getting the sum value correctly. When I am summing it's rounding off. How can I get exact summed value?
Avoid Rouding Off in Parallel Job, 7.5.2 version
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 71
- Joined: Mon Jul 09, 2007 1:12 pm
-
- Participant
- Posts: 71
- Joined: Mon Jul 09, 2007 1:12 pm
Here is what I did that seems to solve the issue.SBSA_DW2 wrote:you may want to do a search on this environment variable: APT_DECIMAL_INTERM_ROUND_MODE
APT_DECIMAL_INTERM_ROUND_MODE
Specifies the default rounding mode for any decimal intermediate
variables required in calculations. The default is round_inf.
(1) Added these 3 parameters to my job.
$APT_DECIMAL_INTERM_PRECISION = 38
$APT_DECIMAL_INTERM_ROUND_MODE = Round toward negative infinity
$APT_DECIMAL_INTERM_SCALE = 11
(2) In transformer, defined a column Decimal(17,11) and derived value using below formula
StringToDecimal((1936.27000000000,'floor')) *1/2,'floor') + StringToDecimal( (StringToDecimal(1432.12340000000 ,'floor')) *1/2,'floor')
(3) Then I moved the value of variable to another column defined as varchar 17.
All calculations seems to keep the precision of 11