Skip to content

Resource and/or tag recommendation: guide to floating point numbers. #73

@lxnn

Description

@lxnn

I think this website would be a useful place to point people who are confused by the results they get when they compare floating point numbers in their code: https://floating-point-gui.de

I propose we introduce a tag for this. Something along the lines of:

Some fractional numbers cannot be represented exactly as binary floating point numbers. So when comparing floating point numbers it's usually best to include a margin of error: test that they are similar rather than exactly equal.

Instead of:

if x == y:
    ...

Try:

if abs(x - y) < epsilon:
    ...

Where epsilon is a small number.

See this website for more information: floating-point-guide.de

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: resourcesRelated to resources listed on the sitestaff meetingWe will discuss this issue at our next staff meeting

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions