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

1**NaN is 1, but any numeric operation with NaN should be NaN (say 1**NaN) #5752

Closed
p6rt opened this issue Oct 16, 2016 · 9 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Oct 16, 2016

Migrated from rt.perl.org#129894 (status was 'rejected')

Searchable as RT129894$

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From @AlexDaniel

*Code​:*
say 0**NaN;
say 1**NaN;
say 2**NaN;

*Output​:*
NaN
1
NaN

See also IRC log​: https://irclog.perlgeek.de/perl6-dev/2016-10-16#i_13412758

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From @zoffixznet

More, at nqp level​:

<Zoffix> m​: use nqp; dd nqp​::pow_n(NaN, 0e0)
<camelia> rakudo-moar 2b5226​: OUTPUT«1e0␤»
<Zoffix> m​: use nqp; dd nqp​::pow_n(1e0, NaN)
<camelia> rakudo-moar 2b5226​: OUTPUT«1e0␤»

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

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

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From @zoffixznet

This was uncovered by coverage work and the num case is fudged in Raku/roast@47aba2d2ea

Once fixed, more tests will be needed for this ticket, but please unfudge that test as well.

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From @AlexDaniel

Just for the record, another case​:

Code​:
say NaN**0

Output​:
1

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

From @usev6

On Sun Oct 16 11​:07​:16 2016, alex.jakimenko@​gmail.com wrote​:

Just for the record, another case​:

Code​:
say NaN**0

Output​:
1

There was an earlier RT for this one (coming to the conclusion that 1 is a reasonable answer here)​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=124450. It has a link to a discussion from stackoverflow -- to me the following comment
was interesting​: http://stackoverflow.com/a/17865226

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

From @zoffixznet

So that leaves nqp​::pow_n(1e0, NaN) == 1e0. Is that also part of IEEE?

I see that Perl 5 gives a NaN for NaN**0, but 1 for 1**NaN​:

zoffix@​VirtualBox​:~$ perl -wlE 'say -sin(9**9**9)**0'
NaN
zoffix@​VirtualBox​:~$ perl -wlE 'say 1**-sin(9**9**9)'
1

On Mon Oct 17 00​:25​:15 2016, bartolin@​gmx.de wrote​:

On Sun Oct 16 11​:07​:16 2016, alex.jakimenko@​gmail.com wrote​:

Just for the record, another case​:

Code​:
say NaN**0

Output​:
1

There was an earlier RT for this one (coming to the conclusion that 1
is a reasonable answer here)​:
https://rt-archive.perl.org/perl6/Ticket/Display.html?id=124450. It has a link to a
discussion from stackoverflow -- to me the following comment
was interesting​: http://stackoverflow.com/a/17865226

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

From @zoffixznet

I took a gander at 2008 IEEE 754 standard and section "9.2.1 Special values" has this to say​:

  pow (x, ±0) is 1 for any x (even a zero, quiet NaN, or infinity)
  pow (+1, y) is 1 for any y (even a quiet NaN)

So our behaviour is correct. Rejecting.

On Mon Oct 17 03​:05​:33 2016, cpan@​zoffix.com wrote​:

So that leaves nqp​::pow_n(1e0, NaN) == 1e0. Is that also part of IEEE?

I see that Perl 5 gives a NaN for NaN**0, but 1 for 1**NaN​:

zoffix@​VirtualBox​:~$ perl -wlE 'say -sin(9**9**9)**0'
NaN
zoffix@​VirtualBox​:~$ perl -wlE 'say 1**-sin(9**9**9)'
1

On Mon Oct 17 00​:25​:15 2016, bartolin@​gmx.de wrote​:

On Sun Oct 16 11​:07​:16 2016, alex.jakimenko@​gmail.com wrote​:

Just for the record, another case​:

Code​:
say NaN**0

Output​:
1

There was an earlier RT for this one (coming to the conclusion that 1
is a reasonable answer here)​:
https://rt-archive.perl.org/perl6/Ticket/Display.html?id=124450. It has a link to a
discussion from stackoverflow -- to me the following comment
was interesting​: http://stackoverflow.com/a/17865226

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

@zoffixznet - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant