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

min(NaN, Inf) is Inf but max(NaN, Inf) is NaN #5129

Open
p6rt opened this issue Feb 10, 2016 · 3 comments
Open

min(NaN, Inf) is Inf but max(NaN, Inf) is NaN #5129

p6rt opened this issue Feb 10, 2016 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Feb 10, 2016

Migrated from rt.perl.org#127506 (status was 'open')

Searchable as RT127506$

@p6rt
Copy link
Author

p6rt commented Feb 10, 2016

From @AlexDaniel

Code​:
say min NaN, Inf, -Inf;
say max NaN, Inf, -Inf;

Result​:
-Inf
NaN

See IRC log​: http://irclog.perlgeek.de/perl6/2016-02-10#i_12017068

@p6rt
Copy link
Author

p6rt commented Jul 22, 2016

From @zoffixznet

Question for @​LARRY​: what should the results be here for min/max/minmax?


Currently, we're using `cmp` semantics and there are spec tests for Inf cmp NaN case​: https://github.com/perl6/roast/blob/a217b1a385eedee0259eb4e2b743304479a01bb5/S03-operators/cmp.t#L68

In this case, those semantics produce these weird results, however. Most weird is probably what `minmax` produces​:

<Zoffix> m​: say minmax NaN, Inf, -Inf;
<camelia> rakudo-moar d789da​: OUTPUT«-Inf..NaN␤»

Per conversation today (http://irclog.perlgeek.de/perl6-dev/2016-07-22#i_12884721 ), IEEE spec says comparisons with NaN should result in a NaN.

Referring to the conversation linked in the OP, mathematically, it sorta makes sense to ignore NaNs and return -Inf..Inf/Inf/-Inf as results. However, NaNs in a program would likely appear as a result of some errors or anomalies. I would not want my code to to just silently ignore them.

Thus, my vote is to have min/max return a NaN if any of the values is a NaN. minmax would return a NaN..NaN

--
Cheers,
ZZ | https://twitter.com/zoffix

@p6rt
Copy link
Author

p6rt commented Jul 22, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the at_larry label Jan 5, 2020
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

1 participant