Eliminating leading 0 in the number

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
murur
Participant
Posts: 19
Joined: Wed Apr 14, 2004 7:55 am

Eliminating leading 0 in the number

Post by murur »

I have to suppress the leading 0

Example

input output

00000123.2340 => 123.2340
00012345.6700 => 12345.67
12345678.9801 => 12345678.9801

how do I implement this in fmt function?

Thanks,
auvray.muriel
Participant
Posts: 43
Joined: Wed Feb 19, 2003 7:17 am
Location: France - Paris
Contact:

Post by auvray.muriel »

Hello,

the function should be used:

FMT('Arg1', '14RZ')

the function TRIM should be imbricated

TRIM(FMT('Arg1', '14RZ'))

:wink:

Muriel
crouse
Charter Member
Charter Member
Posts: 204
Joined: Sun Oct 05, 2003 12:59 pm
Contact:

Post by crouse »

Or just Trim(String,0,"L") to trim "L"eading 0's.
Craig Rouse
Griffin Resouces, Inc
www.griffinresources.com
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The absolutely fastest way is to add zero to the number.

DataStage arithmetic always returns the shortest possible string.

This will also remove trailing zeroes after the decimal point, which was an unstated part of your requirement but indicated in one of your examples.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
lebos
Participant
Posts: 74
Joined: Mon Jan 20, 2003 10:02 am
Location: USA

Post by lebos »

I typically multiply by 1. Is adding zero faster than multiplying by 1?

Larry
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In every computer I've ever encountered (and we're going WAY back here!) addition and subtraction have required fewer machine cycles than multiplication and division. With today's fast processors the difference is unlikely to be noticeable until you get to very large numbers of arithmetic operations (that is, rows processed by DataStage in this case).
In short, YES.
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