Multiplying data column in awk - can rounding be suppressed?
Hi.
I have a large XYZ data file. Columns X and Y contain x-positions and y-positions - both are in metres. Column Z holds data values. I have to pass this data file in to a code - but firstly the x,y positions have to be converted to kilometres. My problem is that awk rounds the values upon multiplication by 0.001 - leading to a loss of data accuracy: Code:
awk -v OFS="\t" '{print $1*0.001, $2*0.001, $3}' datafile Thanks. |
formatted printing takes care of it:
Code:
awk '{printf "%8.3f %8.3f %5.2f\n", $1*0.001, $2*0.001, $3}' datafile |
use printf instead of print :
Quote:
|
All times are GMT -5. The time now is 01:34 AM. |