Page 1 of 1

Eliminating leading 0 in the number

Posted: Thu Apr 22, 2004 11:52 am
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,

Posted: Thu Apr 22, 2004 12:04 pm
by auvray.muriel
Hello,

the function should be used:

FMT('Arg1', '14RZ')

the function TRIM should be imbricated

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

:wink:

Muriel

Posted: Thu Apr 22, 2004 1:01 pm
by crouse
Or just Trim(String,0,"L") to trim "L"eading 0's.

Posted: Thu Apr 22, 2004 4:06 pm
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.

Posted: Fri Apr 23, 2004 6:54 am
by lebos
I typically multiply by 1. Is adding zero faster than multiplying by 1?

Larry

Posted: Sun Apr 25, 2004 4:52 pm
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.