From c8722a9799832942ff219f4ae881f44985c35924 Mon Sep 17 00:00:00 2001 From: Jay Belanger Date: Wed, 16 Oct 2013 22:37:05 -0500 Subject: [PATCH] * calc/calc-comb.el (math-prime-test): Don't assume large integers are represented by lists. * doc/misc/calc.el (Data Type Formats): Don't specify the size at which integers begin to be represented by lists. --- doc/misc/ChangeLog | 5 +++++ doc/misc/calc.texi | 13 ++++++++----- lisp/ChangeLog | 5 +++++ lisp/calc/calc-comb.el | 10 ++++++++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index a05a9f67ac..76d3954cfc 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,3 +1,8 @@ +2013-10-17 Jay Belanger + + * calc.el (Data Type Formats): Don't specify the size at + which integers begin to be represented by lists. + 2013-10-14 Xue Fuqiao * cl.texi (Argument Lists): Add indexes for &key and &aux. diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi index b2b054ec1e..04160eafad 100644 --- a/doc/misc/calc.texi +++ b/doc/misc/calc.texi @@ -33306,12 +33306,15 @@ Lisp integers. This is the only storage format for Calc data objects which is not a Lisp list. Large integers are stored as lists of the form @samp{(bigpos @var{d0} -@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or -@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers -@mathit{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer -from 0 to 999. The least significant digit is @var{d0}; the last digit, +@var{d1} @var{d2} @dots{})} for sufficiently large positive integers +(where ``sufficiently large'' depends on the machine), or +@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative +integers. Each @var{d} is a base-@expr{10^n} ``digit'' (where again, +@expr{n} depends on the machine), a Lisp integer from 0 to +99@dots{}9. The least significant digit is @var{d0}; the last digit, @var{dn}, which is always nonzero, is the most significant digit. For -example, the integer @mathit{-12345678} is stored as @samp{(bigneg 678 345 12)}. +example, the integer @mathit{-12345678} might be stored as +@samp{(bigneg 678 345 12)}. The distinction between small and large integers is entirely hidden from the user. In @code{defmath} definitions, the Lisp predicate @code{integerp} diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 914826db0b..542a9108d3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-10-17 Jay Belanger + + * calc/calc-comb.el (math-prime-test): Don't assume large integers are + represented by lists. + 2013-10-16 Glenn Morris * tmm.el (tmm--history): New dynamic variable. diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el index e09bef0b5c..1a2d609219 100644 --- a/lisp/calc/calc-comb.el +++ b/lisp/calc/calc-comb.el @@ -815,8 +815,14 @@ (list nil v) '(t)))) ((not (equal n (car math-prime-test-cache))) - (cond ((= (% (nth 1 n) 2) 0) '(nil 2)) - ((= (% (nth 1 n) 5) 0) '(nil 5)) + (cond ((if (consp n) + (= (% (nth 1 n) 2) 0) + (= (% n 2) 0)) + '(nil 2)) + ((if (consp n) + (= (% (nth 1 n) 5) 0) + (= (% n 5) 0)) + '(nil 5)) (t (let ((q n) (sum 0)) (while (not (eq q 0)) (setq sum (% -- 2.20.1