Skip to content

Flag floating point literals that have more digits than necessary #1629

Open
@dominikh

Description

@dominikh

For example,

x := 159.9999313354492045391452847979962825775146484375
y := 159.99993133544920453914528479799628257751464843749

and

x := 159.99993133544922
y := 159.9999313354492

are the same.

As usual, floating point numbers are crazy and I'm not sure that flagging these won't cause trouble in some bizarre edge case. Even if it doesn't, maybe it should only be a quickfix, so that people can copy & paste physical constants at very high precision without triggering an error.

Of course realistically, people should use constants for such numbers and it wouldn't make sense to flag uses of those constants, e.g. in x := math.Pi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionWe have to decide if this check is feasible and desirablenew-check

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions