Skip to content

Comparison of NaN #514

Description

@nlohmann

JSON values can store double precision floating-point numbers, including NaN. This is a problem when we compare two JSON values j1 and j2, because j1 == j2 ultimately returns j1.m_value.number_float == j2.m_value.number_float. The latter returns false for NaN, so two JSON values which are bitwise equal are treated unequal because of this.

Would it be a good idea to change the semantics of == in this regard to evaluate json(NAN) == json(NAN) to true? What do you think?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions