bug#12350: Composites identified as primes in factor.c (when HAVE_GMP)
From:
Torbjorn Granlund
Subject:
bug#12350: Composites identified as primes in factor.c (when HAVE_GMP)
Date:
Fri, 07 Sep 2012 20:09:32 +0200
User-agent:
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix)
Jim Meyering <address@hidden> writes:
uintmax_t is used throughout coreutils, but nowhere (that comes to mind)
does it fail when UINTMAX_MAX happens to be different than 2^64-1.
What I was wondering is how many systems have a uintmax_t that is
only 32 bits wide. Now that I reread, I suppose this code would be
ok (albeit slower) with uintmax_t wider than 64.
The code with work with longlong.h iff W_TYPE_SIZE is defined to the
bitsize of uintmax_t.
Any place you can add a reference would be most welcome.
I have added comments here and there. More comments might be desirable.
Here's one where I'd appreciate a reference in a comment:
#define MAGIC64 ((uint64_t) 0x0202021202030213ULL)
#define MAGIC63 ((uint64_t) 0x0402483012450293ULL)
#define MAGIC65 ((uint64_t) 0x218a019866014613ULL)
#define MAGIC11 0x23b
I added a comment explaining these constants.
Here is a new version of the code. It now has GMP factoring code,
updated from the GMP demos code.