EXACTNUMERIC and Rounding of Digits

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
asitagrawal
Premium Member
Premium Member
Posts: 273
Joined: Wed Oct 18, 2006 12:20 pm
Location: Porto

EXACTNUMERIC and Rounding of Digits

Post by asitagrawal »

Hi,

Initially my problem was with arithmetic operations of number with larger singinifcant number of digits, but this was solved by using string mathematics functions.

But now, I also need to use FIX function to round of to 2 digits.
eg. Original Function: FIX(Input.FOREIGN_AMOUNT*(Input.RATE_MULT/Input.RATE_DIV),2,0) and after switching to String maths, the function is FIX(SMUL(Input.AMT,SDIV(Input.RATE_DID,Input.RATE_MULT)),2,0)

Now, using SMUL and SDIV have solved my problem of handling large numbes, but FIX is becoming a bottleneck, as it is rounding off the digits after 16th position. I have changed EXACTNUMERIC to variuos values say, 28, 36 and 57, but no change !!

The stes follwed for changing the EXACTNUMERIC were:
1. Logoff all users from DS
2. Edit uvconfig, and change EXACTNUMERIC to a new value
3. uvregen
4. Restart DS
5. uvregen -t ( It reflects the changes being applied)

Please advice
Share to Learn, and Learn to Share.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What do you believe the second and third arguments of Fix() actually do?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
asitagrawal
Premium Member
Premium Member
Posts: 273
Joined: Wed Oct 18, 2006 12:20 pm
Location: Porto

Post by asitagrawal »

the second argument specifies the PRECISION and the third argument specifies whether rounding has to happen or truncation.

In my case I need to round off to the second decimal position, but in case the number is big enough, eg.
Input

Code: Select all

AMT = 12345678901234567890123.123
RATE_MULT = 1.25500001
RATE_DIV = 1.12345678
Output:

Code: Select all

FIX(Input.AMT*(Input.RATE_MULT/Input.RATE_DIV),2,0) = 13791208901250500000000

FIX(SMUL(Input.AMT,SDIV(Input.RATE_DID,Input.RATE_MULT)),2,0)  = 13791208901250400000000

The expected Output is 13791208901250452834020.19

Currently I am achieving this by using SDIV(SMUL(Amt,RateMult),RateDiv,2)

And my problem is that why FIX is unable to handle this big number ?
Share to Learn, and Learn to Share.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I suspect that that's just the way Fix() is. There's nothing obvious in the documentation (the DataStage BASIC manual). You could always use Fmt() or Oconv() to do your rounding.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
asitagrawal
Premium Member
Premium Member
Posts: 273
Joined: Wed Oct 18, 2006 12:20 pm
Location: Porto

Post by asitagrawal »

ok.. I ll test these functions.. thanks
Share to Learn, and Learn to Share.
Post Reply