Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/primes No need to cast double to ubig (aka uintmax_t) ...
details: https://anonhg.NetBSD.org/src/rev/f9feb62b5d21
branches: trunk
changeset: 768995:f9feb62b5d21
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Tue Aug 30 02:58:04 2011 +0000
description:
No need to cast double to ubig (aka uintmax_t) through int.
This change prevents a modulo by zero in a invocation such as:
primes 18446744073709551000 18446744073709551615
on a LP64 machine.
diffstat:
games/primes/primes.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diffs (32 lines):
diff -r fe3ba8c2b86e -r f9feb62b5d21 games/primes/primes.c
--- a/games/primes/primes.c Tue Aug 30 02:53:01 2011 +0000
+++ b/games/primes/primes.c Tue Aug 30 02:58:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: primes.c,v 1.18 2010/05/13 17:52:12 tnozaki Exp $ */
+/* $NetBSD: primes.c,v 1.19 2011/08/30 02:58:04 jakllsch Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)primes.c 8.5 (Berkeley) 5/10/95";
#else
-__RCSID("$NetBSD: primes.c,v 1.18 2010/05/13 17:52:12 tnozaki Exp $");
+__RCSID("$NetBSD: primes.c,v 1.19 2011/08/30 02:58:04 jakllsch Exp $");
#endif
#endif /* not lint */
@@ -305,11 +305,10 @@
/* note highest useful factor and sieve spot */
if (stop-start > TABSIZE+TABSIZE) {
tab_lim = &table[TABSIZE]; /* sieve it all */
- fact_lim = (int)sqrt(
- (double)(start)+TABSIZE+TABSIZE+1.0);
+ fact_lim = sqrt((double)(start)+TABSIZE+TABSIZE+1.0);
} else {
tab_lim = &table[(stop-start)/2]; /* partial sieve */
- fact_lim = (int)sqrt((double)(stop)+1.0);
+ fact_lim = sqrt((double)(stop)+1.0);
}
/* sieve for factors >= 17 */
factor = 17; /* 17 is first prime to use */
Home |
Main Index |
Thread Index |
Old Index