Skip to content

Comparison of objects containing floats #639

@amrcode

Description

@amrcode

The operator==() method for json objects uses '==' on the underlying number_float_t type. This may result in false negatives and is contrary to the function's documentation which states "Floating-point numbers are compared indirectly: two floating-point numbers f1 and f2 are considered equal if neither f1 > f2 nor f2 > f1 holds". Could this behavior be changed to abs(f1 - f2) < std::numeric_limits<number_float_t>::epsilon() ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions