Subject: calc prime test fails for numbers > 8 million

From: Glenn Morris <[email-masked]>
Date: Tue, 15 Oct 2013 20:32:15 -0400

Package: emacs
Version: 24.3

On x86_64 GNU/Linux:

emacs -Q -f calc
8000000 RET
k p
  -> Wrong type argument: listp, 8000000

Any number >= 8000000 (but < math-small-integer-size) fails in this way.

The problem is the

  (% (nth 1 n) 2) 0)

of math-prime-test, which still expects numbers larger than 8000000 to
be in (bigpos ... ) list format, but the limit is much greater than that
these days.

The calc manual is likewise outdated:

  19.5.7.1 Data Type Formats
  [...]
  Large integers are stored as lists of the form `(bigpos D0 D1 D2 ...)'
  for positive integers 1000000 or more,

(First reported at
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679753 )