Page 1 of 1

Simple division in Transformer stage results in zero

Posted: Thu Sep 08, 2005 7:45 am
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.

Posted: Thu Sep 08, 2005 9:59 am
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.

Posted: Thu Sep 08, 2005 10:52 am
by pauldblake
Thanks Naveen.

I have tried using the 46528/86400 and the Div syntax and both return the same zero result.

Posted: Thu Sep 08, 2005 1:08 pm
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

Posted: Thu Sep 08, 2005 1:25 pm
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

Posted: Thu Sep 08, 2005 4:13 pm
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).

Posted: Fri Sep 09, 2005 3:56 am
by pauldblake
Thanks guys.

The AsFloat solution works fine.