Mismatch in summing a column in UNIX

Hello,

I am facing issue in summing up a column in unix.I am displaying a column sum up to 4 decimal places and below is the code snippet

sed '1d' abc.csv | cut -d',' -f7 | awk '{s+=$1}END{ printf("%.4f\n",s)}'
 
-170552450514.8603
 

example of data values in the column(not more than 2 precisions)
-4994532.04
-2218492.52
-167183.69
103093000.43
123444.23

The issue is that,if I sum the column in excel sheet (with 4 precisions) it is coming to
-170552450514.8600 and in unix its
-170552450514.8603.

I am not sure what is causing the difference.Could you please help me with this

Can you post all the values in code tags, you are trying to sum? Could be a rounding vs no rounding issue? If your values are rounded to 2 decimal places, I don't understand how can the sum go to 4 decimal places without padding 0s?

there are 3703 rows..please find the attachment

Your file is not an XLS. Renaming it XLS has not made it actually be an XLS.

awk does not have infinite precision. If you need infinite precision, use the bc tool. If you can convince awk to print a list of lines like

a=-9992411.01
a=a+(-4992005.13)
...
a

and feed that into bc, it will print a total.

awk -F, 'NR==1 { print "a=",$7 ; next }  { print "a=a+("$7")"; } END { print "a" }' inputfile.csv | bc