Skip to content

Floating point repr #6136

Closed
Closed
@anntzer

Description

@anntzer
In [1]: np.array(.1)[()] == np.array(.1).item()
Out[1]: True

In [2]: np.array(.1)[()] # a np.float64
Out[2]: 0.10000000000000001

In [3]: np.array(.1).item() # a python (64-bit) float
Out[3]: 0.1

Python floats use the shortest repr that give the same value when eval'd since https://bugs.python.org/issue1580 was accepted. It would be nice if numpy did the same.

I realize it would require a nontrivial patch :)

Metadata

Metadata

Assignees

No one assigned

    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