Skip to content

Issue converting strings with _ to mpf #613

@oscargus

Description

@oscargus

From Python 3.7 it is possible to use _ in strings converted to floats (and maybe other types), so float('1_2.3_4') is valid and gives 12.34.

This causes a problem when converting this type of numbers using from_str or more exactly here:
https://github.com/fredrik-johansson/mpmath/blob/c11db84b3237bd8fc6721f5a0c5d7c0c98a24dc1/mpmath/libmp/libmpf.py#L1303-L1306

Should be solved by replacing parts[1].rstrip('0') with parts[1].rstrip('0').replace('_', '').

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnew feature requests (or implementation)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions