diff options
author | Garrett Wollman <wollman@FreeBSD.org> | 1996-07-18 18:53:15 +0000 |
---|---|---|
committer | Garrett Wollman <wollman@FreeBSD.org> | 1996-07-18 18:53:15 +0000 |
commit | 1ecaa8a894a883d724247cbe133117ae09202fb0 (patch) | |
tree | b6478e67c004577a191e133e676433c80465a1e5 /lib/libc/stdtime/difftime.c | |
parent | 9fbfdd118f426911a57179856fdba1133719faf4 (diff) |
Notes
Diffstat (limited to 'lib/libc/stdtime/difftime.c')
-rw-r--r-- | lib/libc/stdtime/difftime.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libc/stdtime/difftime.c b/lib/libc/stdtime/difftime.c index c8cd286d12bae..f178524f5152f 100644 --- a/lib/libc/stdtime/difftime.c +++ b/lib/libc/stdtime/difftime.c @@ -1,8 +1,11 @@ - +/* +** This file is in the public domain, so clarified as of +** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +*/ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)difftime.c 7.4"; +static char elsieid[] = "@(#)difftime.c 7.7"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -45,9 +48,7 @@ const time_t time0; /* ** Repair delta overflow. */ - hibit = 1; - while ((hibit <<= 1) > 0) - continue; + hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1); /* ** The following expression rounds twice, which means ** the result may not be the closest to the true answer. @@ -67,10 +68,10 @@ const time_t time0; ** This problem occurs only with very large differences. ** It's too painful to fix this portably. ** We are not alone in this problem; - ** many C compilers round twice when converting + ** some C compilers round twice when converting ** large unsigned types to small floating types, ** so if time_t is unsigned the "return delta" above - ** has the same double-rounding problem. + ** has the same double-rounding problem with those compilers. */ return delta - 2 * (long_double) hibit; } |