Roundup routine

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
kool_cons
Participant
Posts: 68
Joined: Thu Jul 07, 2005 3:41 pm

Roundup routine

Post by kool_cons »

Hi,

Does anyone have a routine to ROUNDUP a number? I would appreciate your help.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The INT() function will return 1 for 1.499 and 2 for 1.50001. Is this what you are looking for?
kool_cons
Participant
Posts: 68
Joined: Thu Jul 07, 2005 3:41 pm

Post by kool_cons »

This is what i need..

ROUNDUP(31415.00, -2) Rounds 31415 up to 2 decimal places to the left of the decimal ((31500)..This is MS excel function,i am converting this formula in Datastage. Is there any other function which works as above.

.I guess int() can give 31415 only for this example.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Try to explore FMT() function. You can do similar things using it.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I would just use simple math; you can write your own roundup routine:

Roundup(Value,Places)

Code: Select all

   Shift = 10**Places
   Ans = INT(Value*Shift)/Shift
Hmmm, this could actually be an inline transform as well.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The INT() function is not what you want. The FIX() function will be close. Use 0 for the mode argument to get correct arithmetic rounding.

Code: Select all

FIX(number, precision, mode)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kool_cons
Participant
Posts: 68
Joined: Thu Jul 07, 2005 3:41 pm

Post by kool_cons »

Thanks i am have written a small routine with Int. this is working fine.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I'm surprised. On my system Int(1.50001) returned 1. This does not accord with the original requirement. Int() returns the largest integer smaller than the argument.
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