Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual result of 'the same' expression #45

Closed
Darkriser opened this issue Mar 23, 2018 · 3 comments
Closed

Dual result of 'the same' expression #45

Darkriser opened this issue Mar 23, 2018 · 3 comments
Labels

Comments

@Darkriser
Copy link

Darkriser commented Mar 23, 2018

Let's have an expression 'max(0/0,1)' and mathematically equal
expression 'max(1,0/0)'. I expect (why shouldn't I ?) to get the same results.
However, muParser calculates
max(0/0,1) = -nan(ind)
max(1,0/0) = 1
max(1,0/0,1) = 1

Verified using the latest commit from Jan 23 2018 (6cf2746)
and an older version 2.2.4 (more than 2yrs old).
Is there a bug or my expectations are incorrect?

Thanks in advance,
Marcel

@beltoforion
Copy link
Owner

That is a bug, your expectations are fine. The result should probably be NaN in both cases since the NaN is tainting the result.

@Darkriser
Copy link
Author

Darkriser commented Mar 27, 2018

I noticed that muParser uses std::max and std::min functions internally.
So I verified their behavior using a plain C++ code and received the same results.
I'll ask about this on some C++ devel forums, muParser seems to be above suspicion...

Edit:
int main(void)
{
double a{10.0};
double n{std::nan("")};

std::cout << std::max(a, n) << std::endl;
std::cout << std::max(n, a) << std::endl;
}

@beltoforion beltoforion added wontfix and removed bug labels Jun 2, 2020
@beltoforion
Copy link
Owner

closed; If the behavior of std::max is the reason there is nothing i can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants