Skip Menu |

This queue is for tickets about the Math-Polynomial CPAN distribution.

Report information
The Basics
Id: 28998
Status: resolved
Priority: 0/
Queue: Math-Polynomial

People
Owner: hasch-cpan [...] cozap.com
Requestors: tdahlheim [...] gmx.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.04
Fixed in: 1.001



Subject: Zero polynomial stringifies to empty string in verbose mode
Distribution: M/MH/MHASCH/Math-Polynomial-0.04.tar.gz The zero polynomial gets converted to the empty string when verbose mode is turned on: perl -MMath::Polynomial -e 'Math::Polynomial->verbose(1); $p = Math::Polynomial->new(0); print "$p\n"' This is certainly unexpected and arguably a bug. Attached is a patch to return "0" in this case.
Subject: Polynomial.pm.diff
--- Polynomial.pm.orig 2007-08-26 18:46:44.000000000 +0200 +++ Polynomial.pm 2007-08-26 19:05:46.000000000 +0200 @@ -419,12 +419,19 @@ $exp--; } - if (@terms && $terms[0] eq $CONFIG{PLUS}) { - # If there's a plus first, drop it. - shift(@terms); - } elsif (@terms) { - # Otherwise, remove any spaces around the first minus. - $terms[0] =~ tr/ //d; + if (@terms) { + if ($terms[0] eq $CONFIG{PLUS}) { + # If there's a plus first, drop it. + shift(@terms); + } else { + # Otherwise, remove any spaces around the first minus. + $terms[0] =~ tr/ //d; + } + } + else { + # We are dealing with the zero polynomial, + # so show the term '0'. + push(@terms, 0); } return join('', @terms); } else {