1

awk high precision arithmetic

view story
linux-howto

http://unix.stackexchange.com – I am looking for a way to tell awk to do high-precision arithmetic in a substitution operation. This involves, reading a field from a file and substituting it with a 1% increment on that value. However, I am losing precision there. Here is a simplified reproduction of the problem: $ echo 0.4970436865354813 | awk '{gsub($1, $1*1.1)}; {print}' 0.546748 Here, I have a 16 digit after decimal precision but awk gives only six. Using printf, I am getting the same result: $ echo 0.4970436865354813 | awk '{gsub($1, $1*1.1)}; {printf("%.16G\n", $1)}' 0.546748 Any suggestions on to how to get t (HowTos)