fix undefined function and add integer divisions

Fix a undefined function and some floats which appear through division and are used as slice indices.
Loosely based on the patch in https://bugs.launchpad.net/ubuntu/+source/python-numpy/+bug/701549