hello,
when I type the following command
awk -v varc="$i" '{ new=($1*varc)} { print new }'
it gives outputs in 5 decimal. How can I set my outputs to 9 decimal by using awk.
thanks
hello,
when I type the following command
awk -v varc="$i" '{ new=($1*varc)} { print new }'
it gives outputs in 5 decimal. How can I set my outputs to 9 decimal by using awk.
thanks
Hi.
Use printf instead of print.
i.e.
{printf "%.9f\n", new}
I imagine it only gives you 5 because that's all the precision there is?
hi scottn thank you for your quick reply. My last question is that
for two variable, following line does not work
awk -v varc="$i" '{ a1new=($1*varc); a2new=($2*varc)} { printf "%.9f\n, a1new" "a2new " }'
what is wrong ?
If you have two values you need two format parameters
{ printf "%.9f %.9f\n", a1new, a2new }
it works. many thanks
or:
awk -v varc="$i" -v OFMT='%.9f' '{ a1new=($1*varc); a2new=($2*varc)} { print a1new, a2new}'