[Cython] signed vs. unsigned range

Marcin Cieślik marcin.cieslik at gmail.com
Tue Sep 2 05:14:36 CEST 2008


Hello,
I just wanted to make shure that this how it is intended to be:
My intention was to code this C-loop:
for (i=j-1;i>=0;i--)

def pycount(n):
    for j in range(1, n):
        print j
        for i in range(j-1, -1, -1):
            print i

def cycount_unsigned(unsigned int n):
    cdef unsigned int i, j
    for j in range(1, n):
        print j
        for i in range(j-1, -1, -1):
            print i

def cycount_signed(int n):
    cdef int i, j
    for j in range(1, n):
        print j
        for i in range(j-1, -1, -1):
            print i

In [2]: sign.pycount(3)
1
0
2
1
0

In [3]: sign.cycount_unsigned(3)
1
2

In [4]: sign.cycount_signed(3)
1
0
2
1
0

Yours,
Marcin


More information about the Cython-dev mailing list