Closed GoogleCodeExporter closed 9 years ago
definitely look like problems specific to x86-64 and probably specific to the
unit tests. Thanks for reporting
them! Unfortunately I don't have a 64-bit Linux box to check them in more
depth.
The hash(z) problem appears to be fixed in the current svn HEAD, since that
specific test has changed; that
change was part of revision 14, i.e.
brain:~/gmpy/test alex$ svn diff -r13 gmpy_test_mpz.py
[snip]
->>> hash(z)
--791330233
+>>> hash(z) == hash(long(z))
+True
The other issue, however -- the one with:
ix(_g.mpz(sys.maxint)) == sys.maxint
is news to me. Could I ask you, or anybody with a 64-bit linux install, to try
at an interactive Python prompt:
>>> import gmpy, sys, operator
>>> sys.maxint
...whatever...
>>> operator.index(sys.maxint)
...whatever...
>>> gmpy.mpz(sys.maxint)
...whatever...
>>> operator.index(gmpy.mpz(sys.maxint))
...whatever...
and copy and paste that brief session here? Seeing the results should tell me
enough to fix the test (or, less
likely, to show me that the test is fine and there is some x86-64 specific
issue to fix w/the gmpy code).
Again, thanks!
Alex
Original comment by alea...@gmail.com
on 23 May 2007 at 4:21
definitely look like problems specific to x86-64 and probably specific to the
unit tests. Thanks for reporting
them! Unfortunately I don't have a 64-bit Linux box to check them in more
depth.
The hash(z) problem appears to be fixed in the current svn HEAD, since that
specific test has changed; that
change was part of revision 14, i.e.
brain:~/gmpy/test alex$ svn diff -r13 gmpy_test_mpz.py
[snip]
->>> hash(z)
--791330233
+>>> hash(z) == hash(long(z))
+True
The other issue, however -- the one with:
ix(_g.mpz(sys.maxint)) == sys.maxint
is news to me. Could I ask you, or anybody with a 64-bit linux install, to try
at an interactive Python prompt:
>>> import gmpy, sys, operator
>>> sys.maxint
...whatever...
>>> operator.index(sys.maxint)
...whatever...
>>> gmpy.mpz(sys.maxint)
...whatever...
>>> operator.index(gmpy.mpz(sys.maxint))
...whatever...
and copy and paste that brief session here? Seeing the results should tell me
enough to fix the test (or, less
likely, to show me that the test is fine and there is some x86-64 specific
issue to fix w/the gmpy code).
Again, thanks!
Alex
Original comment by alea...@gmail.com
on 23 May 2007 at 4:21
(sorry for the repeated comment -- some issue w/code.google.com -- it gave me
an error msg but it actually
did accept my comment!)
Alex
Original comment by alea...@gmail.com
on 23 May 2007 at 4:23
Here is what you requested;
>>> import gmpy, sys, operator
>>> sys.maxint
9223372036854775807
>>> operator.index(sys.maxint)
9223372036854775807
>>> gmpy.mpz(sys.maxint)
mpz(-1)
>>> operator.index(gmpy.mpz(sys.maxint))
-1
Note also:
>>> gmpy.mpz(1 << 31)
mpz(2147483648)
>>> gmpy.mpz(1 << 32)
mpz(0)
.
.
.
>>> gmpy.mpz(1 << 62)
mpz(0)
>>> gmpy.mpz(1 << 63)
mpz(9223372036854775808L)
Gary Bunting
Original comment by bunting....@gmail.com
on 23 May 2007 at 5:44
Changing the declaration of get_zconst (line 279 of gmpy.c) from
static PympzObject* get_zconst(int i)
to
static PympzObject* get_zconst(long i)
fixes the problem.
The call to get_zconst(i) from mpz_from_c_long(long i) was looking
at only the low 32 bits of i.
Gary Bunting
Original comment by bunting....@gmail.com
on 25 May 2007 at 3:34
Gary's fix looks good (and doesn't break tests on a 32-bit machine;
unfortunately I
don't have access to a 64-bit one to check!) so I uploaded it to subversion's
HEAD
(revision 17) -- thanks Gary!
Original comment by alea...@gmail.com
on 30 May 2007 at 6:06
Original issue reported on code.google.com by
bunting....@gmail.com
on 22 May 2007 at 11:15