summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/params.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e3162f21..8498c5954 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-26  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* Stephane: 38020: fix problems with fractions of a second in
+	$SECONDS.
+
 2016-02-25  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* 38024: Src/signals.c, Test/C03traps.ztst: improve 37999 to
diff --git a/Src/params.c b/Src/params.c
index 8bd8a8eee..7c5f79fff 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3804,8 +3804,8 @@ intsecondsgetfn(UNUSED(Param pm))
 
     gettimeofday(&now, &dummy_tz);
 
-    return (zlong)(now.tv_sec - shtimer.tv_sec) +
-	(zlong)(now.tv_usec - shtimer.tv_usec) / (zlong)1000000;
+    return (zlong)(now.tv_sec - shtimer.tv_sec -
+		  (now.tv_usec < shtimer.tv_usec ? 1 : 0));
 }
 
 /* Function to set value of special parameter `SECONDS' */
@@ -3823,7 +3823,7 @@ intsecondssetfn(UNUSED(Param pm), zlong x)
     shtimer.tv_sec = diff;
     if ((zlong)shtimer.tv_sec != diff)
 	zwarn("SECONDS truncated on assignment");
-    shtimer.tv_usec = 0;
+    shtimer.tv_usec = now.tv_usec;
 }
 
 /**/