8000 MPZ arithmetic errors with DIG_SIZE == MPZ_DIG_SIZE · Issue #6777 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
MPZ arithmetic errors with DIG_SIZE == MPZ_DIG_SIZE #6777
Closed
@mipy123

Description

@mipy123

There are some (potentially dangerous) arithmetic errors often occurring with long 100% CPU delays with the Unix port defaults (cannot test other ports) when dealing with large numbers.

CPython:
>>> (2**256 - 2**32)**2 // (2**256 - 2**32) 115792089237316195423570985008687907853269984665640564039457584007908834672640

MicroPython 1.13 (takes approximately 1 minute):
>>> (2**256 - 2**32)**2 // (2**256 - 2**32) 1766847064778390606685032887445983096815437806911733293014036620377194496

MicroPython 1.13 (immediate, with DIG_SIZE = MPZ_DIG_SIZE - 1):
>>> (2**256 - 2**32)**2 // (2**256 - 2**32) 115792089237316195423570985008687907853269984665640564039457584007908834672640

Is it safe to change the default DIG_SIZE to MPZ_DIG_SIZE - 1?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpy-coreRelates to py/ directory in source

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0