Rounding Issue

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
jagadam
Premium Member
Premium Member
Posts: 107
Joined: Wed Jul 01, 2009 4:55 pm
Location: Phili

Rounding Issue

Post by jagadam »

I Have an issue here . My values I want to have like this

10690164.245 as 10690164.25
-2374823.085 as 2374823.09

But When I do the below options I am getting results not as expected
Doing a DecimalToDecimal(Column," ").

Any Suggestions is appreciated

round_inf

10690164.245 10690164.24
-2374823.085 2374823.09

Ceil

10690164.245 10690164.25
-2374823.085 2374823.08

floor

10690164.245 10690164.24
-2374823.085 2374823.09
NJ
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

floor and ceil are giving correct results (assuming you're applying that before removing the sign).

From memory, the behaviour of rounding is determined additionally by whether the preceding digit is odd or even when the least significant digit is 5. Try it with 10690164.345.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jagadam
Premium Member
Premium Member
Posts: 107
Joined: Wed Jul 01, 2009 4:55 pm
Location: Phili

Post by jagadam »

Hi Ray,
U might be right on the even , odd digit on the preceeding digit.But I need ouput of 10690164.245 as 10690164.25 As in oracle rouding is getting to 10690164.245 as 10690164.25 not in datastage .My Unit testing is failing because of this.Is there anything we can do for this

In Datastage It is doing Round half to odd for Tie breaking
In Oracle It was doing Round half away from zero.

How can we get the desired results in Datastage ?
NJ
jagadam
Premium Member
Premium Member
Posts: 107
Joined: Wed Jul 01, 2009 4:55 pm
Location: Phili

Post by jagadam »

Any Suggestions on this please let me know.Is this a bug on Datastage
NJ
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I don't see a bug or a problem here.

Rounding "10690164.245" to 2 decimal places gives "10690164.25" using nearest value.

You could force matters by doing a trunc_zero after adding 0.005 to positive numbers or subtracting 0.005 from negative ones.
jagadam
Premium Member
Premium Member
Posts: 107
Joined: Wed Jul 01, 2009 4:55 pm
Location: Phili

Post by jagadam »

Hi Andrw,
If that the case then If I have a value of 10690164.244 instead then I will have 10690164.244 +.005 =10690164.249 ==> 10690164.25 .Which is not I wanted ...

DS Rounding mechanism is using Round half to odd for Tie breaking
This is the issue I am talking about adding .005 affects other records which are not tie breaking

Let me know If I am missing anything in here
NJ
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

In my experience with this I have learnt that there are many ways a rounding function can be implemented, like Accounting etc. DataStage does it this way. Other tools might use a different algorithm. ArndW is right, there is no bug with this.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
Post Reply