فهرست منبع

Eggert tuneups

SCCS-file: difftime.c
SCCS-SID: 7.6
Arthur David Olson 30 سال پیش
والد
کامیت
7ffbb96c5e
1فایلهای تغییر یافته به همراه3 افزوده شده و 5 حذف شده
  1. 3 5
      difftime.c

+ 3 - 5
difftime.c

@@ -43,9 +43,7 @@ const time_t	time0;
 	/*
 	/*
 	** Repair delta overflow.
 	** 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 following expression rounds twice, which means
 	** the result may not be the closest to the true answer.
 	** the result may not be the closest to the true answer.
@@ -65,10 +63,10 @@ const time_t	time0;
 	** This problem occurs only with very large differences.
 	** This problem occurs only with very large differences.
 	** It's too painful to fix this portably.
 	** It's too painful to fix this portably.
 	** We are not alone in this problem;
 	** 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,
 	** large unsigned types to small floating types,
 	** so if time_t is unsigned the "return delta" above
 	** 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;
 	return delta - 2 * (long_double) hibit;
 }
 }