Page 1 of 2

Issue with ABS and MOD Function in Parallel Extender Job

Posted: Thu Mar 18, 2010 12:41 am
by gvstrao
Hi Everyone,
When I am tring to apply the MOD function , Its removing decimal spaces . Can anyone hellp me in this.

EX: Source Data ( X = -12.90 )
Expected Data = 5.43


The Given Logic should be apply in my job :
--------------------------------------------------
ABS(X) MOD 7.47
--------------------------------------------------

When I apply the given logic in the stage variable, decimal portion is going off.

Stage variable logic = MOD(ABS(-12.90),7.47)

Getting result = 5

but I need the value 5.43

Can any one help in this..

Thank you inadvance.

GVSTRAO

Posted: Thu Mar 18, 2010 3:06 am
by ArndW
The MOD function uses integer divisors and returns an integer value.

Posted: Thu Mar 18, 2010 3:22 am
by rohithmuthyala
Divide 12.90 with the value 7.47 and store the result as an integer. Then multiply this integer value with 7.47 and subtract this result from 12.90.

Posted: Thu Mar 18, 2010 3:54 am
by Sainath.Srinivasan
Or remove their decimals before applying the function and reformat later.

One way is to multiply by 100 before and divide by 100 later.

Posted: Thu Mar 18, 2010 5:35 am
by rohithmuthyala
Multiplying with 100 will help only if the number has two decimal places.

Posted: Thu Mar 18, 2010 5:44 am
by chulett
There seems to be a disconnect between what the MOD() function actually does and what they want it to do. :?

Posted: Thu Mar 18, 2010 7:27 am
by nikhilanshuman
Mod function returns "Remainder" of a division which can never be decimal.

Posted: Thu Mar 18, 2010 10:20 am
by Sainath.Srinivasan
It can very much be decimal. It is the remainder and not the quotient.

For example,
Mod(12.3, 7.5) => 4.8

Posted: Thu Mar 18, 2010 10:50 am
by ArndW
Nope, the documentation states that the divisor and remainder are integers.

Posted: Thu Mar 18, 2010 10:59 am
by Sainath.Srinivasan
I was referring to the mod function in general and not specific to DataStage. If it truncates, I assume, it is a bug.

Posted: Thu Mar 18, 2010 12:07 pm
by chulett
Trouble is, this is all about the DataStage function so how it works "in general" is pretty much irrelevant, I'm afraid.

Posted: Thu Apr 08, 2010 3:52 am
by ShaneMuir
Was this ever resolved, as it seems to be the most over engineered solution to a simple subtraction I have seen in a while. Isn't the OP just trying subract 7.47 from 12.90? Or is that pure coincidence?

Posted: Thu Apr 08, 2010 4:03 am
by san0907
Can you just try with Fabs functions instaed of ABS function.Please let me know the result how it works.

Posted: Thu Apr 08, 2010 12:53 pm
by anbu
Modulus returns the remainder which is not mere subtraction.

Posted: Thu Apr 08, 2010 4:29 pm
by ray.wurlod
Fabs() is a server job function. It's only available in parallel jobs in the BASIC Transformer stage.