Fix some warning about loss of precision data in iec_std_lib.h file.
authorEdouard Tisserant
Thu, 25 Oct 2012 11:09:06 +0200
changeset 639 f0ef73eceb57
parent 638 049748e9410a
child 701 562c01f82afb
Fix some warning about loss of precision data in iec_std_lib.h file.
lib/iec_std_lib.h
--- a/lib/iec_std_lib.h	Tue Oct 23 11:32:49 2012 +0200
+++ b/lib/iec_std_lib.h	Thu Oct 25 11:09:06 2012 +0200
@@ -295,18 +295,18 @@
 }
 static inline TIME __time_mul(TIME IN1, LREAL IN2){
   LREAL s_f = IN1.tv_sec * IN2;
-  time_t s = s_f;
-  div_t ns = div((LREAL)IN1.tv_nsec * IN2, 1000000000);
-  TIME res = {s + ns.quot,
-              ns.rem + (s_f - s) * 1000000000 };
+  time_t s = (time_t)s_f;
+  div_t ns = div((int)(IN1.tv_nsec * IN2), 1000000000);
+  TIME res = {(long)s + ns.quot,
+		      (long)ns.rem + (s_f - s) * 1000000000 };
   __normalize_timespec(&res);
   return res;
 }
 static inline TIME __time_div(TIME IN1, LREAL IN2){
   LREAL s_f = IN1.tv_sec / IN2;
-  time_t s = s_f;
-  TIME res = {s,
-              IN1.tv_nsec / IN2 + (s_f - s) * 1000000000 };
+  time_t s = (time_t)s_f;
+  TIME res = {(long)s,
+              (long)(IN1.tv_nsec / IN2 + (s_f - s) * 1000000000) };
   __normalize_timespec(&res);
   return res;
 }
@@ -482,9 +482,9 @@
     while(--l > 0 && IN.body[l] != '.');
     if(l != 0){
         LREAL IN_val = atof((const char *)&IN.body);
-        return  (TIME){IN_val, (IN_val - (LINT)IN_val)*1000000000};
+        return  (TIME){(long)IN_val, (long)(IN_val - (LINT)IN_val)*1000000000};
     }else{
-        return  (TIME){__pstring_to_sint(&IN), 0};
+        return  (TIME){(long)__pstring_to_sint(&IN), 0};
     }
 }