summaryrefslogtreecommitdiffstats
path: root/games/factor
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1999-01-06 19:46:56 +0000
committerimp <imp@FreeBSD.org>1999-01-06 19:46:56 +0000
commit3936fe2a01920fe1fb3d7bf34ade29da706ff55e (patch)
tree9e52f1eef381c301d448ae2228de398bfba81ead /games/factor
parentf261ff0eff417c843bfdc277cfb7162762478375 (diff)
downloadFreeBSD-src-3936fe2a01920fe1fb3d7bf34ade29da706ff55e.zip
FreeBSD-src-3936fe2a01920fe1fb3d7bf34ade29da706ff55e.tar.gz
Fix printf errors in the hflag case.
Fix old bug with bogus casing to (long). Document the true limits of factor on 64-bit architectures. Submitted by: bde
Diffstat (limited to 'games/factor')
-rw-r--r--games/factor/factor.612
-rw-r--r--games/factor/factor.c10
2 files changed, 11 insertions, 11 deletions
diff --git a/games/factor/factor.6 b/games/factor/factor.6
index 4844780..316abdd 100644
--- a/games/factor/factor.6
+++ b/games/factor/factor.6
@@ -52,12 +52,12 @@ factor, primes \- factor a number, generate primes
.SH DESCRIPTION
The
.I factor
-utility will factor integers between 0 and 4294967295 inclusive.
-When a number is factored, it is printed, followed by a ``:'',
-and the list of factors on a single line.
-Factors are listed in ascending order, and are preceded by a space.
-If a factor divides a value more than once, it will be printed
-more than once.
+utility will factor integers between 0 and ULONG_MAX (4294967295 on 32
+bit architectures, 18446744073709551615 on 64 bit ones), inclusive.
+When a number is factored, it is printed, followed by a ``:'', and the
+list of factors on a single line. Factors are listed in ascending
+order, and are preceded by a space. If a factor divides a value more
+than once, it will be printed more than once.
.PP
When
.I factor
diff --git a/games/factor/factor.c b/games/factor/factor.c
index c5fdbaa..aa64dd5 100644
--- a/games/factor/factor.c
+++ b/games/factor/factor.c
@@ -173,7 +173,7 @@ pr_fact(val)
}
/* Factor value. */
- (void)printf(hflag ? "0x%x:" : "%lu:", val);
+ (void)printf(hflag ? "0x%lx:" : "%lu:", val);
for (fact = &prime[0]; val > 1; ++fact) {
/* Look for the smallest factor. */
do {
@@ -183,15 +183,15 @@ pr_fact(val)
/* Watch for primes larger than the table. */
if (fact > pr_limit) {
- (void)printf(hflag ? " 0x%x" : " %lu", val);
+ (void)printf(hflag ? " 0x%lx" : " %lu", val);
break;
}
/* Divide factor out until none are left. */
do {
- (void)printf(hflag ? " 0x%x" : " %lu", *fact);
- val /= (long)*fact;
- } while ((val % (long)*fact) == 0);
+ (void)printf(hflag ? " 0x%lx" : " %lu", *fact);
+ val /= *fact;
+ } while ((val % *fact) == 0);
/* Let the user know we're doing something. */
(void)fflush(stdout);
OpenPOWER on IntegriCloud