Timeline for How can I quickly sum all numbers in a file?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 28, 2015 at 12:40 | comment | added | Janis | Let me explain that. - There is just one case where s can be empty; if the input data contains no lines (i.e. if there is no input at all). In that case there are two behaviours possible; 1) no input => no output, or 2) always output something, if only 0. Both are sensible options depending on the application context. The +0 is addressing option 2). To address option 1) you'd rather have to write END {if(s) print s}. - Therefore it makes no sense to assume either option (for this corner case of no data) until it is specified by the question. | |
| May 27, 2015 at 18:20 | comment | added | cuonglm | You need s+0 in case where s is empty, it will print 0 instead of empty. | |
| May 27, 2015 at 18:19 | history | rollback | Janis | Rollback to Revision 1 | |
| May 27, 2015 at 18:18 | history | edited | cuonglm | CC BY-SA 3.0 | added 4 characters in body |
| May 27, 2015 at 18:14 | history | answered | Janis | CC BY-SA 3.0 |