diff --git a/LOG b/LOG index c21f0350ef..338572ad40 100644 --- a/LOG +++ b/LOG @@ -1359,3 +1359,5 @@ - added MinGW/MSYS build support for Windows and configuration for Travis-CI testing of all Windows builds BUILDING, .travis*, wininstall/Makefile +- fix multiply of -2^30 to itself on 64-bit platforms + number.c, 5_3.ms, release_notes.stex diff --git a/c/number.c b/c/number.c index 97bee865bd..4e39685fe0 100644 --- a/c/number.c +++ b/c/number.c @@ -637,9 +637,13 @@ static ptr big_mul(tc, x, y, xl, yl, sign) ptr tc, x, y; iptr xl, yl; IBOOL sign return copy_normalize(&BIGIT(W(tc),0),xl+yl,sign); } -#define SHORTMIN (most_negative_fixnum / (1 << (fixnum_bits / 2))) -#define SHORTMAX (most_positive_fixnum / (1 << (fixnum_bits / 2))) -#define SHORTRANGE(x) ((x) >= SHORTMIN && (x) <= SHORTMAX) +/* SHORTRANGE is -floor(sqrt(most_positive_fixnum))..floor(sqrt(most_positive_fixnum)). + We don't use sqrt because it rounds up for fixnum_bits = 61 */ +#if (fixnum_bits == 30) +#define SHORTRANGE(x) (-23170 <= (x) && (x) <= 23170) +#elif (fixnum_bits == 61) +#define SHORTRANGE(x) (-0x3FFFFFFF <= (x) && (x) <= 0x3FFFFFFF) +#endif ptr S_mul(x, y) ptr x, y; { ptr tc = get_thread_context(); diff --git a/mats/5_3.ms b/mats/5_3.ms index e169c138c1..9a3296faa2 100644 --- a/mats/5_3.ms +++ b/mats/5_3.ms @@ -1599,6 +1599,30 @@ (error? (* 'a 3 4)) (error? (* 3 5 'a 4)) (eqv? (* 1 2) 2) + (eqv? (* 23170 23170) 536848900) + (eqv? (* 23170 -23170) -536848900) + (eqv? (* -23170 23170) -536848900) + (eqv? (* -23170 -23170) 536848900) + (eqv? (* 23171 23170) 536872070) + (eqv? (* 23171 -23170) -536872070) + (eqv? (* -23171 23170) -536872070) + (eqv? (* -23171 -23170) 536872070) + (eqv? (* 23171 23171) 536895241) + (eqv? (* 23171 -23171) -536895241) + (eqv? (* -23171 23171) -536895241) + (eqv? (* -23171 -23171) 536895241) + (eqv? (* #x3FFFFFFF #x3FFFFFFF) #xFFFFFFF80000001) + (eqv? (* #x3FFFFFFF #x-3FFFFFFF) #x-FFFFFFF80000001) + (eqv? (* #x-3FFFFFFF #x3FFFFFFF) #x-FFFFFFF80000001) + (eqv? (* #x-3FFFFFFF #x-3FFFFFFF) #xFFFFFFF80000001) + (eqv? (* #x40000000 #x3FFFFFFF) #xFFFFFFFC0000000) + (eqv? (* #x40000000 #x-3FFFFFFF) #x-FFFFFFFC0000000) + (eqv? (* #x-40000000 #x3FFFFFFF) #x-FFFFFFFC0000000) + (eqv? (* #x-40000000 #x-3FFFFFFF) #xFFFFFFFC0000000) + (eqv? (* #x40000000 #x40000000) #x1000000000000000) + (eqv? (* #x40000000 #x-40000000) #x-1000000000000000) + (eqv? (* #x-40000000 #x40000000) #x-1000000000000000) + (eqv? (* #x-40000000 #x-40000000) #x1000000000000000) (fl~= (* 1.0 2) 2.0) (fl~= (* 1 2.0) 2.0) (eqv? (* 3/5 2/5) 6/25) diff --git a/release_notes/release_notes.stex b/release_notes/release_notes.stex index d28f060243..bf544ed770 100644 --- a/release_notes/release_notes.stex +++ b/release_notes/release_notes.stex @@ -1695,6 +1695,11 @@ in fasl files does not generally make sense. %----------------------------------------------------------------------------- \section{Bug Fixes}\label{section:bugfixes} +\subsection{Muliplication of $-2^{30}$ by itself on 64-bit platforms (9.5.3)} + +A bug that produced the wrong sign when multiplying $-2^{30}$ by +itself on 64-bit platforms has been fixed. + \subsection{Compiler dropping affects from record-accessor calls (9.5.3)} A bug that could cause the source optimizer to drop effects within