bug in cdivision implementation

4 views
Skip to first unread message

William Stein

unread,
Nov 6, 2010, 7:50:41 PM11/6/10
to cython-users
Hi,

I'm using "Cython version 0.13", included with Sage. There is (in
my opinion) a bug in the cdivision=False implementation. With the
"cdivision=False" command line option, the following two lines do
completely different things:

n = n % k

versus

n %= k

Here's a Sage notebook session illustrating exactly this:

{{{id=8|
%cython

def f():
cdef int n = -7, k = 11
n = n % k
print n
///
}}}

{{{id=7|
f()
///
4
}}}

{{{id=9|
%cython

def f():
cdef int n = -7, k = 11
n %= k
print n
///
}}}

{{{id=10|
f()
///
-7
}}}


The Sage library is build with cdivision=True, but the %cython mode in
the notebook using cdivision=False.


--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Robert Bradshaw

unread,
Nov 8, 2010, 6:13:23 PM11/8/10
to cython...@googlegroups.com
On Sat, Nov 6, 2010 at 4:50 PM, William Stein <wst...@gmail.com> wrote:
> Hi,
>
> I'm using "Cython version 0.13", included with Sage.    There is (in
> my opinion) a bug in the cdivision=False implementation.

Yep, that's a bug.

http://trac.cython.org/cython_trac/ticket/591

- Robert

Reply all
Reply to author
Forward
0 new messages