Rounding off decimal values

Hi Friends,

This is my last post for today.

My input file is

chr1 100 200
chr1 123 300
chr1 300 400 
chr1 420 520
chr10 132344343 132348674

When I try using this command

awk '{v=($3+$2)/2; print $0"\t"v}' 1

This is my output

chr1 100 200	150
chr1 123 300	211.5
chr1 300 400 	350
chr1 420 520	470
chr10 132344343 132348674	1.32347e+08

But, I want to round off the 0.5s to nearest whole number and I dont want the exponential notation. Instead, I would like to see the real number

So, my final output would be

chr1 100 200	150
chr1 123 300	212
chr1 300 400 	350
chr1 420 520	470
chr10 132344343 132348674	132346509 (This one is rounded of from the exponential notation which is 132346508.5)
echo '123.798' | awk '{printf "%.0f\n",$0}'
1 Like
awk 'BEGIN{CONVFMT="%.0f"}{v=($3+$2)/2; print $0"\t"v}'  file
1 Like