Error in multiplication

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
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Error in multiplication

Post by cosec »

I have a column A with value ( 8.0000) and Column B ( 21.4300)

When I multiply Column A and B My value should be 171.44 but the answer I get is 171.50. The target column is (15,2)

If I substitute the input link by the real values the result is ok but otherwise no..how do i fix it
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you actually multiply the 2 numbers together you will get the correct answer (try writing a routine with the code

Code: Select all

Ans = "8.0000" * "21.4300"
and you can see that DS does the math correctly. So your rounding is happening somewhere outside of that statement. What is your target stage where you are seeing the rounded value?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What are the SQL data types of the two input columns? Are you using Data Elements?

Have you used the Debugger or active stage tracing to ensure that the incoming values are what you believe them to be?

Please execute the following query from the Command window in Administrator:

Code: Select all

SELECT EVAL "8.0000 * 21.4300", 8.0000 * 21.4300 FROM VOC FIRST 1;
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Error in multiplication

Post by sachin1 »

hello, i have used oracle datatype numeric format example of precision and scale, for example column A(length=5,precision=4) value=8.0000
column B(length=6,precision=4) value=21.4300.
and i am getting values as 171.44. (Length=15,scale=2)

with other formating of numeric fields, it works fine. please check your datatype and its length(precision).
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Re: Error in multiplication

Post by SURA »

Hi Man,

Just increase the Target column length (in the file) Precision by 1.It will work in both the cases (15,3) or (16,3)

Thanks,
Ram.
cosec wrote:I have a column A with value ( 8.0000) and Column B ( 21.4300)

When I multiply Column A and B My value should be 171.44 but the answer I get is 171.50. The target column is (15,2)

If I substitute the input link by the real values the result is ok but otherwise no..how do i fix it
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The ark had come to dry land and Noah exhorted all the animals to go forth and multiply. He came upon two snakes who seemed to be unwilling to move. "Didn't you hear me tell all the animals to go forth and multiply," Noah asked them. "We can't," they said, "we're adders".
:lol:
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