From 2e4a578a87a9cdce0e6e26fb226ae6ba1254c90f Mon Sep 17 00:00:00 2001
From: Nils Steinger <git@n-st.de>
Date: Sun, 28 May 2017 11:08:09 +0200
Subject: [PATCH] Improved compatibility with mawk

mawk defaults to scientific notation for integers > (2^31 - 1), while gawk
doesn't.
Work around this using %.0f format string.
---
 nench.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/nench.sh b/nench.sh
index c3bc127..bee0106 100755
--- a/nench.sh
+++ b/nench.sh
@@ -75,11 +75,11 @@ dd_benchmark()
                 io=$NF
             }
             END {
-                if (io ~ /TB\/s/) {print 1000*1000*1000*1000*io}
-                else if (io ~ /GB\/s/) {print 1000*1000*1000*io}
-                else if (io ~ /MB\/s/) {print 1000*1000*io}
-                else if (io ~ /KB\/s/) {print 1000*io}
-                else { print 1*io}
+                if (io ~ /TB\/s/) {printf("%.0f\n", 1000*1000*1000*1000*io)}
+                else if (io ~ /GB\/s/) {printf("%.0f\n", 1000*1000*1000*io)}
+                else if (io ~ /MB\/s/) {printf("%.0f\n", 1000*1000*io)}
+                else if (io ~ /KB\/s/) {printf("%.0f\n", 1000*io)}
+                else { printf("%.0f", 1*io)}
             }'
     rm -f test_$$
 }
@@ -189,7 +189,7 @@ else
     printf '    3rd run:    %s\n' "$(printf '%d\n' "$io3" | Bps_to_MiBps)"
 
     # Calculating avg I/O (better approach with awk for non int values)
-    ioavg=$( awk 'BEGIN{print int(('"$io1"' + '"$io2"' + '"$io3"')/3)}' )
+    ioavg=$( awk 'BEGIN{printf("%.0f", ('"$io1"' + '"$io2"' + '"$io3"')/3)}' )
     printf '    average:    %s\n' "$(printf '%d\n' "$ioavg" | Bps_to_MiBps)"
 fi