Skip to content

Invalid integer division (for negative divisors) #534

@skirpichev

Description

@skirpichev

See failure example from CI:
https://github.com/diofant/python-gmp/actions/runs/16988919362/job/48163779956

    def test_divmod_bulk(x, y):
        mx = mpz(x)
        my = mpz(y)
        if not y:
            with pytest.raises(ZeroDivisionError):
                mx // my
            return
        r = x // y
>       assert mx // my == r
E       assert (mpz(0) // mpz(-9223372036854739465)) == -1
E       Falsifying example: test_divmod_bulk(
E           x=0,
E           y=-9_223_372_036_854_739_465,
E       )

This doesn't "work" locally for me (graalpy-24.2.1-linux-amd64), but following works:

>>> ((0) // (-92233720368547394651))  # should be 0
-1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions