From 9ba2fac36714b8114af4d335ad5497e3d7b84360 Mon Sep 17 00:00:00 2001
From: reiniscirpons <rc234@st-andrews.ac.uk>
Date: Thu, 23 Nov 2023 16:16:59 +0000
Subject: [PATCH] Fix divide by zero error of x86

---
 src/sims1.cpp | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/sims1.cpp b/src/sims1.cpp
index 87dc1f25b..4e0db77c1 100644
--- a/src/sims1.cpp
+++ b/src/sims1.cpp
@@ -824,7 +824,7 @@ namespace libsemigroups {
     // ReporterV3
     auto now           = std::chrono::high_resolution_clock::now();
     auto time_total_ns = duration_cast<nanoseconds>(now - start_time());
-    auto time_total_s  = duration_cast<seconds>(time_total_ns);
+    auto time_total_s  = duration_cast<seconds>(time_total_ns).count();
     auto time_diff     = duration_cast<nanoseconds>(now - last_report());
 
     // Stats
@@ -841,15 +841,21 @@ namespace libsemigroups {
        signed_group_digits(count_diff),
        signed_group_digits(total_pending_diff));
     rc("Sims1: mean         {} (cong./s) | {} (node/s)\n",
-       group_digits(stats().count_now / time_total_s.count()),
-       group_digits(stats().total_pending_now / time_total_s.count()));
+       group_digits(time_total_s == 0 ? 0 : stats().count_now / time_total_s),
+       group_digits(
+           time_total_s == 0 ? 0 : stats().total_pending_now / time_total_s));
     rc("Sims1: time last s. {} (/cong.)  | {} (/node)\n",
        count_diff == 0 ? "x" : string_time(time_diff / count_diff),
        total_pending_diff == 0 ? "x"
                                : string_time(time_diff / total_pending_diff));
     rc("Sims1: mean time    {} (/cong.)  | {} (/node)\n",
-       string_time(time_total_ns / stats().count_now.load()),
-       string_time(time_total_ns / stats().total_pending_now.load()));
+       string_time(stats().count_now.load() == 0
+                       ? decltype(time_total_ns / stats().count_now.load())(0)
+                       : time_total_ns / stats().count_now.load()),
+       string_time(
+           stats().total_pending_now.load() == 0
+               ? decltype(time_total_ns / stats().total_pending_now.load())(0)
+               : time_total_ns / stats().total_pending_now.load()));
     rc("Sims1: time         {} (total)   |\n", string_time(time_total_ns));
 
     last_report(now);