Skip to content

BUG: not assigning full precision values to longdouble scalars #4381

@scottransom

Description

@scottransom

If you try to set a longdouble scalar with a string, it appears to go through Python's normal string-parsing and therefore gets converted to a C double rather than a long double:

In [19]: numpy.longdouble("1.12345678901234567890")
Out[19]: 1.1234567890123456912

Note the loss of those last couple digits.

In [20]: numpy.float("1.12345678901234567890")
Out[20]: 1.1234567890123457

In [21]: numpy.longdouble("1.12345678901234567890") - numpy.float("1.12345678901234567890")
Out[21]: 0.0

And so internally they are identical.

One solution to this is a special case for longdoubles and to use strtold() to do the conversion.

Cheers,

Scott

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions