Issue in round of and exponential value

we are facing an issue where the sum of column value is getting rounded of before and after decimal.

[edmgr@lcosedd nad]$  awk -F "|" '{{sum = sum + $11}} END{print sum}' ARINSO_GLD001.txt
6.07398e+07   -- initial value

 [edmgr@lcosedd nad]$  awk -F "|" '{{sum = sum + $11}} END{print sum}' ARINSO_GLD001.txt | awk '{ print sprintf("%.5f", $1); }'
60739800.00000 -- after removing exponential spaces.

but the actual sum is 60739766.08

Please assist :frowning:

awk uses double precision arithmetic - which means on most systems you have 15 digits of precision.

What you are doing is defeating that. Try:

awk -F "|" '{{sum = sum + $11}} END{printf("%11.3f\n", sum) }' ARINSO_GLD001.txt
1 Like

Thanks Jim , it really works.