Simple division in Transformer stage results in zero

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
pauldblake
Participant
Posts: 5
Joined: Thu Apr 28, 2005 8:57 am

Simple division in Transformer stage results in zero

Post by pauldblake »

The following division in a Transformer stage results in zero.

Div(46528,86400)

Expected result = 0.538518519

I have tried data types (Length = 40, Scale = 30) of Decimal, Double, Float and Numeric without success.

Any help would be appreciated.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Paul,

If all you want to do is simple division, then you can use

Code: Select all

46528/86400
in your tranformer and it will work correctly

My guess is that when you do

Code: Select all

Div(46528,86400)
, the Div function treats the arguments as string and it expects a number.
Thanks,
Naveen
pauldblake
Participant
Posts: 5
Joined: Thu Apr 28, 2005 8:57 am

Post by pauldblake »

Thanks Naveen.

I have tried using the 46528/86400 and the Div syntax and both return the same zero result.
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Paul,

I tried this method in a server job, as I dont have access to parallel job right now and it works well. I wonder if its different in parallel jobs :roll:

Code: Select all

46528/86400
Thanks,
Naveen
Woth
Participant
Posts: 24
Joined: Thu Mar 18, 2004 8:18 pm

Post by Woth »

All the operands of the equations HAVE to be of the same type.
In your case:

asFloat((asFloat(46528) / asFloat(86400)))

0.5385185480


Hope it helps
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Div() performs integer division. It is documented as doing so. Wolfgang's solution using AsFloat is about as elegant as you're going to get (you may need to adjust the outer function according to your requirements, for example AsDecimal).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pauldblake
Participant
Posts: 5
Joined: Thu Apr 28, 2005 8:57 am

Post by pauldblake »

Thanks guys.

The AsFloat solution works fine.
Post Reply