diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-03-04 20:42:52 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-03-04 20:43:20 -0800 |
commit | 19b554f154738b1dd3824b0034af74938a2b6187 (patch) | |
tree | f35d91ac0a11d07476dc0f50169040345877a738 | |
parent | 8250f4c6d0375f4eeb053cbd2245cd83666b2e0e (diff) | |
download | gnulib-19b554f154738b1dd3824b0034af74938a2b6187.tar.gz |
dtotimespec: simplify
* lib/dtotimespec.c (dtotimespec): Simplify.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/dtotimespec.c | 10 |
2 files changed, 7 insertions, 8 deletions
@@ -1,3 +1,8 @@ +2017-03-04 Paul Eggert <eggert@cs.ucla.edu> + + dtotimespec: simplify + * lib/dtotimespec.c (dtotimespec): Simplify. + 2017-03-04 Bruno Haible <bruno@clisp.org> test-calloc-gnu: Reenable test also for GCC 7. diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c index 9d81b68d81..3ca5a9cfd3 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 { |