Round to nearest tenth

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
collabxchange
Premium Member
Premium Member
Posts: 34
Joined: Thu Aug 28, 2014 8:48 pm
Location: United States

Round to nearest tenth

Post by collabxchange »

Hi,
I searched the forum but couldn't get any answer. Does anyone know how to round a number to nearest equal to higher tenth.

e.g.

12 --> 20
15 --> 20
1.4 --> 10

Thanks!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmmm... mod? Mod by 10 and then add the remainer? Decimal values you may need to round up first, me thinks.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Code: Select all

INT((In.Column+10)/10)*10
or

Code: Select all

(10-MOD(In.Column,10))+In.Column
to name just two methods
FranklinE
Premium Member
Premium Member
Posts: 739
Joined: Tue Nov 25, 2008 2:19 pm
Location: Malvern, PA

Post by FranklinE »

I use the "Ceil" mathematical function for decimal values, and you should see good results from this:

Code: Select all

(Ceil(In.column/10))*10
Franklin Evans
"Shared pain is lessened, shared joy increased. Thus do we refute entropy." -- Spider Robinson

Using mainframe data FAQ: viewtopic.php?t=143596 Using CFF FAQ: viewtopic.php?t=157872
Post Reply