Skip to content

math.ldexp gives incorrect results on Windows #132876

Closed
@tkreuzer

Description

@tkreuzer

Bug report

Bug description:

>>> import math
>>> math.ldexp(6993274598585239, -1126)
5e-324
>>>

The correct result would be 1e-323. This is obviously a bug in the Windows ldexp implementation (it works fine on Linux). But it would be good, if it could be fixed on the CPython side with a workaround.
math.ldexp is used by mpmath to round from multiprecision to float, leading to incorrect rounding on Windows.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions