Skip to content

Modulo operator does not conform to standard Python behavior #207

@avdstaaij

Description

@avdstaaij

In Python, the result of a % b for integers a and b always has the same sign as b. Numpy follows this convention as well. PyGLM, however, does not follow this rule for integer vectors. On my machine:

>>> -3 % 2
1

>>> np.array([-3]) % 2
array([1])

>>> vec2(-3,-3) % 2
vec2(1,1)

>>> ivec2(-3,-3) % 2
ivec2(-1,-1)

I assume the sign is unspecified for pyGLM in the last case.

I've looked in GLM's documentation of the modulo function. While it states that floating point modulo should behave like it does in Python, it does not actually describe an integer modulo operation at all, so it seems like pyGLM is free to choose what to do here.

I would like to request integer modulo to behave in the standard Python way (the same way as floating point modulo). This would reduce confusion and prevent subtle bugs.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions