Skip to content

NaN behaves strangely in a boolean expression #332

@herme063

Description

@herme063

I am using MathParser.org-mxparser 6.1.0, and with the below expressions I am getting strange results:

formula results
[NaN] == 1 NaN
[NaN] == 1 && 0 == 0 NaN
[NaN] == 1 && 1 == 0 0
if([NaN] == 1 && 0 == 0, 1, 2) NaN
if([NaN] == 1 && 1 == 0, 1, 2) 2

I have checked a few programming languages handling of NaN and the equality operator returns false (for C# and Java).
So I was expecting [NaN] == 1 to return 0 above instead of NaN.

What is the logic behind this result?

Also why is the 3rd expression returning 0, compared to the 2nd which is returning NaN?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions