Differences between revisions 2 and 3
Revision 2 as of 2007-02-20 21:11:03
Size: 840
Editor: anonymous
Comment:
Revision 3 as of 2007-02-20 21:32:15
Size: 881
Editor: anonymous
Comment:
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
Expand the sagex package and look at

SageX bug fixing example --- fix the mangled pow() function

Pyrex has an unfortunate bug in the way it handles the power function for cdef integers. Namely

   1 %pyrex
   2 
   3 def foo(int n):
   4     return 2**n

foo(3)
///
8.0

Looking at the c source code we see the the error on line 85

  __pyx_1 = PyFloat_FromDouble(pow(2, __pyx_v_n)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}

Here the c function pow() is being used, which only operates on doubles. This is fine if the return type is a float, but if it is, say, a python object, then this code is incorrect. I will change this so that the resulting type is an integer in this case.

Expand the sagex package and look at

Some useful links:

days3/sprints/sagex (last edited 2008-11-14 13:42:11 by anonymous)