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

Rakudo doesn't report an error on log(0) #406

Closed
p6rt opened this issue Nov 12, 2008 · 8 comments
Closed

Rakudo doesn't report an error on log(0) #406

p6rt opened this issue Nov 12, 2008 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Nov 12, 2008

Migrated from rt.perl.org#60490 (status was 'resolved')

Searchable as RT60490$

@p6rt
Copy link
Author

p6rt commented Nov 12, 2008

From @masak

Rakudo r32568​:

$ ./perl6 -e 'my $result = log(0); say "Still alive after getting $result"'
Still alive after getting -inf

S29​:

=item log

our Num multi method log ( Num $x​: Num :$base = Num​::e ) is export

Logarithm of base C<$base>, default Natural. Calling with C<$x == 0> is an
error.

(Since log is periodic along the imaginary axis, an error should
perhaps be thrown for other complex values as well, provided that
enough precision can be achieved to make this a problem.)

@p6rt
Copy link
Author

p6rt commented Nov 12, 2008

From @pmichaud

On Tue, Nov 11, 2008 at 11​:57​:02PM -0800, Carl Mäsak wrote​:

Rakudo r32568​:

$ ./perl6 -e 'my $result = log(0); say "Still alive after getting $result"'
Still alive after getting -inf

Now fixed in r32574​:

  $ ./parrot perl6.pbc -e 'my $result = log(0); say $result;'
  Can't take log of 0
 
  $

Note that instead of throwing an exception immediately, log(0)
returns a Failure that then throws an exception if it is used.

Pm

@p6rt
Copy link
Author

p6rt commented Nov 12, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 12, 2008

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

From @zoffixznet

Looks like this bug re-appeared and Rakudo's function all come down to nqp​::log_n()​:

  <ZoffixW> m​: say log 0
  <camelia> rakudo-moar 2dd0dd​: OUTPUT«-Inf␤»
  <ZoffixW> m​: use nqp; say nqp​::log_n(0e0)
  <camelia> rakudo-moar 2dd0dd​: OUTPUT«-Inf␤»

2008 IEEE 754[^1], in section 9.2, says log(0) needs to give a divideByZero exception.

[1] http://www.csee.umbc.edu/~tsimo1/CMSC455/IEEE-754-2008.pdf

On Wed Nov 12 07​:53​:52 2008, pmichaud wrote​:

On Tue, Nov 11, 2008 at 11​:57​:02PM -0800, Carl Mäsak wrote​:

Rakudo r32568​:

$ ./perl6 -e 'my $result = log(0); say "Still alive after getting
$result"'
Still alive after getting -inf

Now fixed in r32574​:

$ ./parrot perl6.pbc -e 'my $result = log(0); say $result;'
Can't take log of 0

$

Note that instead of throwing an exception immediately, log(0)
returns a Failure that then throws an exception if it is used.

Pm

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

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

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

From @zoffixznet

I should've read more​:

"Section 7.3 Division by zero", says 'For logB(0) when logBFormat is a floating-point format, the sign of the infinity is minus (−∞).'

And I'm guessing this case matches it, because JVM and C standard lib too give -Inf and nqp just maps the operations to VM's operations.

Reclosing :)

On Mon Oct 17 05​:58​:14 2016, cpan@​zoffix.com wrote​:

Looks like this bug re-appeared and Rakudo's function all come down to
nqp​::log_n()​:

<ZoffixW> m​: say log 0
<camelia> rakudo-moar 2dd0dd​: OUTPUT«-Inf␤»
<ZoffixW> m​: use nqp; say nqp​::log_n(0e0)
<camelia> rakudo-moar 2dd0dd​: OUTPUT«-Inf␤»

2008 IEEE 754[^1], in section 9.2, says log(0) needs to give a
divideByZero exception.

[1] http://www.csee.umbc.edu/~tsimo1/CMSC455/IEEE-754-2008.pdf

On Wed Nov 12 07​:53​:52 2008, pmichaud wrote​:

On Tue, Nov 11, 2008 at 11​:57​:02PM -0800, Carl Mäsak wrote​:

Rakudo r32568​:

$ ./perl6 -e 'my $result = log(0); say "Still alive after getting
$result"'
Still alive after getting -inf

Now fixed in r32574​:

$ ./parrot perl6.pbc -e 'my $result = log(0); say $result;'
Can't take log of 0

$

Note that instead of throwing an exception immediately, log(0)
returns a Failure that then throws an exception if it is used.

Pm

@p6rt
Copy link
Author

p6rt commented Oct 17, 2016

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

@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