how to retain leading zeros

Hi All,

I am working with a fixed width file Forrmat.
C1 Number (10,3)
C2 Number (10,3)

e.g.
c1= 0000000100.000
c2= 0000000020.000
0000000100.0000000000020.000

I have to perform c1 - c2 . i.e. I want answer to be 0000000080.000. but I am loosing the leading zeros( only getting 80.000) when I am manipulating the file using awk. I tired with printf(%10.3f,c1-c2), but i am unable to retain leading zeros in the output.

Is there any way to retain leading zeros. As of now I could think of writing a logic to get the original length of c1 and then padd that many zeros to the final value of c1-c2. Any body has any other thoughts or any easy way to get this?

Thanks,
--Manish

try printf(%013.3f,c1-c2)

It works !!

-- Manish

echo '0000000100.0000000000020.000' | nawk '{c1=substr($0,1,14); c2=substr($0,15); printf("c1->[%s] c2->[%s] diff->[%014.3f]\n", c1, c2, c1-c2)}'