Page 1 of 1

EXACTNUMERIC and Rounding of Digits

Posted: Mon Aug 20, 2007 4:36 am
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

Posted: Mon Aug 20, 2007 5:04 am
by ray.wurlod
What do you believe the second and third arguments of Fix() actually do?

Posted: Mon Aug 20, 2007 5:25 am
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 ?

Posted: Mon Aug 20, 2007 3:24 pm
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.

Posted: Tue Aug 21, 2007 2:01 pm
by asitagrawal
ok.. I ll test these functions.. thanks