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
gvstrao
Premium Member
Posts: 27 Joined: Sun Jun 04, 2006 4:45 pm
Post
by gvstrao » Thu Mar 18, 2010 12:41 am
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
ArndW
Participant
Posts: 16318 Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:
Post
by ArndW » Thu Mar 18, 2010 3:06 am
The MOD function uses integer divisors and returns an integer value.
rohithmuthyala
Participant
Posts: 57 Joined: Wed Oct 21, 2009 4:46 am
Location: India
Post
by rohithmuthyala » Thu Mar 18, 2010 3:22 am
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.
Rohith
Sainath.Srinivasan
Participant
Posts: 3337 Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom
Post
by Sainath.Srinivasan » Thu Mar 18, 2010 3:54 am
Or remove their decimals before applying the function and reformat later.
One way is to multiply by 100 before and divide by 100 later.
rohithmuthyala
Participant
Posts: 57 Joined: Wed Oct 21, 2009 4:46 am
Location: India
Post
by rohithmuthyala » Thu Mar 18, 2010 5:35 am
Multiplying with 100 will help only if the number has two decimal places.
Rohith
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Mar 18, 2010 5:44 am
There seems to be a disconnect between what the MOD() function actually does and what they want it to do.
-craig
"You can never have too many knives" -- Logan Nine Fingers
nikhilanshuman
Participant
Posts: 58 Joined: Tue Nov 17, 2009 3:38 am
Post
by nikhilanshuman » Thu Mar 18, 2010 7:27 am
Mod function returns "Remainder" of a division which can never be decimal.
Nikhil
Sainath.Srinivasan
Participant
Posts: 3337 Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom
Post
by Sainath.Srinivasan » Thu Mar 18, 2010 10:20 am
It can very much be decimal. It is the remainder and not the quotient.
For example,
Mod(12.3, 7.5) => 4.8
ArndW
Participant
Posts: 16318 Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:
Post
by ArndW » Thu Mar 18, 2010 10:50 am
Nope, the documentation states that the divisor and remainder are integers.
Sainath.Srinivasan
Participant
Posts: 3337 Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom
Post
by Sainath.Srinivasan » Thu Mar 18, 2010 10:59 am
I was referring to the mod function in general and not specific to DataStage. If it truncates, I assume, it is a bug.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Thu Mar 18, 2010 12:07 pm
Trouble is, this is all about the DataStage function so how it works "in general" is pretty much irrelevant, I'm afraid.
-craig
"You can never have too many knives" -- Logan Nine Fingers
ShaneMuir
Premium Member
Posts: 508 Joined: Tue Jun 15, 2004 5:00 am
Location: London
Post
by ShaneMuir » Thu Apr 08, 2010 3:52 am
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?
san0907
Participant
Posts: 9 Joined: Thu Jun 25, 2009 1:19 am
Post
by san0907 » Thu Apr 08, 2010 4:03 am
Can you just try with Fabs functions instaed of ABS function.Please let me know the result how it works.
Thanks and Regards
Sana
anbu
Premium Member
Posts: 596 Joined: Sat Feb 18, 2006 2:25 am
Location: india
Post
by anbu » Thu Apr 08, 2010 12:53 pm
Modulus returns the remainder which is not mere subtraction.
You are the creator of your destiny - Swami Vivekananda
ray.wurlod
Participant
Posts: 54607 Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:
Post
by ray.wurlod » Thu Apr 08, 2010 4:29 pm
Fabs() is a server job function. It's only available in parallel jobs in the BASIC Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.