Avoid Rouding Off in Parallel Job, 7.5.2 version

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Avoid Rouding Off in Parallel Job, 7.5.2 version

Post by horserider »

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?
SBSA_DW2
Premium Member
Premium Member
Posts: 37
Joined: Fri Jul 25, 2008 1:24 am

Post by SBSA_DW2 »

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.
horserider
Participant
Posts: 71
Joined: Mon Jul 09, 2007 1:12 pm

Post by horserider »

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.
Here is what I did that seems to solve the issue.

(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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

horserider wrote:$APT_DECIMAL_INTERM_ROUND_MODE = Round toward negative infinity
That doesn't look like any kind of valid APT value... perhaps "round_neg_inf"??? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply