definitive fix of issue #76: remove internal overflow of u64 when calculating least common multiple of task intervals.
authorMario de Sousa <msousa@fe.up.pt>
Wed, 26 Dec 2018 11:40:45 +0000
changeset 1079 585445abc4a2
parent 1077 b37de6a9ad7f
child 1080 54445dfc28ec
definitive fix of issue #76: remove internal overflow of u64 when calculating least common multiple of task intervals.
stage4/generate_c/generate_c.cc
--- a/stage4/generate_c/generate_c.cc	Tue Dec 25 12:15:29 2018 +0000
+++ b/stage4/generate_c/generate_c.cc	Wed Dec 26 11:40:45 2018 +0000
@@ -544,7 +544,7 @@
 /***********************************************************************/
 /***********************************************************************/
 
-#define MILLISECOND 1
+#define MILLISECOND 1000000
 #define SECOND 1000 * MILLISECOND
 
 unsigned long long calculate_time(symbol_c *symbol) {
@@ -649,7 +649,7 @@
       if (least_common_ticktime == 0)
         least_common_ticktime = time;
       else
-        least_common_ticktime = (least_common_ticktime * time) / common_ticktime;
+        least_common_ticktime = least_common_ticktime * (time / common_ticktime);
     }
 
     unsigned long long get_common_ticktime(void) {