Hello,
Can you tell me how can I change this format by awk
Input
0.2057422D-01
0.2463722D-01
-0.1068047D-02
Output
0.02057422
0.02463722
-0.001068047
Thanks
wan
Hello,
Can you tell me how can I change this format by awk
Input
0.2057422D-01
0.2463722D-01
-0.1068047D-02
Output
0.02057422
0.02463722
-0.001068047
Thanks
wan
awk -FD '{print $1}' file_name
sed 's/D-.*//' Input
Maybe it makes it easier for someone to "translate" it in awk...
Edit: sorry, I did not see that extra zeros :rolleyes:
thank you
i try to use this command
awk -FD '{print $1}' file_name
and my output is
0.2057422
0.2463722
-0.1068047
But i want this form
0.02057422
0.02463722
-0.001068047
How can i change is form by using awk
thank you very much
wan
what is the logic in your output ?
I'm out... :rolleyes:
thanks for the reply
I just want to change
From
0.2057422D-01
To
0.022057422
by using awk
Any other idea?
Thanks for this
Your question is becoming increasingly incoherent. Originally you asked how to divide a number by 10, or by 100, then your desired output was not only in a different format, but not even the same number in any format!!
awk '{ print $1+0 }' file
or
awk '{ printf( "%.7f\n"), $1 }'
Hi.
My take on this is that a number like 0.2057422D-01 is not recognized as the double-precision equivalent of 0.2057422E-01, i.e. scientific notation, but from a code which produces the "D" to signify a double-precision result. An example of such a code might be Fortran.
An awk rule like:
{ sub(/D/,"E",$1) ; printf( "%.8f\n"), $1 }
for the input:
0.2057422D-01
0.2463722D-01
-0.1068047D-02
would produce:
0.02057422
0.02463722
-0.00106805
which is rounded for the last number, but produces essentially what the OP desires ... cheers, drl