bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] dtotimespec: simplify


From: Paul Eggert
Subject: [PATCH] dtotimespec: simplify
Date: Sat, 4 Mar 2017 20:44:03 -0800

* lib/dtotimespec.c (dtotimespec): Simplify.
---
 ChangeLog         |  5 +++++
 lib/dtotimespec.c | 10 ++--------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 355f5c8..861dd6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-04  Paul Eggert  <address@hidden>
+
+       dtotimespec: simplify
+       * lib/dtotimespec.c (dtotimespec): Simplify.
+
 2017-03-04  Bruno Haible  <address@hidden>
 
        test-calloc-gnu: Reenable test also for GCC 7.
diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c
index 9d81b68..3ca5a9c 100644
--- a/lib/dtotimespec.c
+++ b/lib/dtotimespec.c
@@ -29,15 +29,9 @@
 struct timespec
 dtotimespec (double sec)
 {
-  double min_representable = TYPE_MINIMUM (time_t);
-  double max_representable =
-    ((TYPE_MAXIMUM (time_t) * (double) TIMESPEC_RESOLUTION
-      + (TIMESPEC_RESOLUTION - 1))
-     / TIMESPEC_RESOLUTION);
-
-  if (! (min_representable < sec))
+  if (! (TYPE_MINIMUM (time_t) < sec))
     return make_timespec (TYPE_MINIMUM (time_t), 0);
-  else if (! (sec < max_representable))
+  else if (! (sec < 1.0 + TYPE_MAXIMUM (time_t)))
     return make_timespec (TYPE_MAXIMUM (time_t), TIMESPEC_RESOLUTION - 1);
   else
     {
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]