Aggregator Totals Mismatch

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Aggregator Totals Mismatch

Post by rameshrr3 »

Hi

Im pretty sure that this has been discussed before, but my searches arent showing any threads.

Im trying to aggregate a flat file column that has 8000+ records. This column is defined as FLOAT. (Business expects data with variable number of digits after decimal point).
The source data is a delimited ASCII file.
The data sample that I have could well be handled by DECIMAL(15,2), but due to the said constraint , i need to define it as FLOAT data. None of the input records has data that contains more than 2 digits after the decimal point.(When seen using an OS Editor or Data browser)

However if I sum up this column using the aggregator stage, the output sum contains 4 digits after the decimal point. ( Again i define the 'sum' column as FLOAT). Now the user group comes back to me and says precision is important, and those 2 extra digits in the sum are a cause for concern. Is there anything that i could do to avoid/bypass this problem?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search the web for information about why computers can not store FLOAT accurately, and the IEEE standards for representing a FLOAT. When a FLOAT is converted for display, there may be an arbitrary number of digits following the decimal point. It is not a DataStage issue; it's because you have chosen to use FLOAT as a data type. FLOAT can not be stored precisely.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

so you requirement is to get only 2 digits after decimal point.

Either you can use round off function to get nearest values after decimal point
or
write a small basic rountine and call it in tranformer stage.
You need to manipulate column value using basic function.
Use string or field funtion to get exact 2 digits after decimal point.

Concatenate before decimal part and after decimal part.
then convert resultant string into float again.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Aggregator Totals Mismatch

Post by chulett »

rameshrr3 wrote:Now the user group comes back to me and says precision is important, and those 2 extra digits in the sum are a cause for concern.
So, precision is important and yet they want a less precise number? :wink:

As noted, round or truncate the result, whichever is appropriate for your user group.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use the Fix() function to specify the largest number of decimal places, then add 0 to that result to remove trailing non-significant zeroes.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply