Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Error:divide by zero

Quote Reply
Error:divide by zero
Hi all,

I am experiencing a fatal error when I am trying to build. The error is an
illegal division by zero at /usr/asd/httpd/cgi-bin/test/li/nph-build.cgi,
line 439, cluster 5222. This situation just recently occured.

I think maybe in this line we can change from:
if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id})/($values[$db_votes] + $votes{$id});

$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
print "\tUpdating rating to $values[$db_rating] for link id $id\n";
}
to :

if (exists $votes{$id}) {
if(($values[$db_votes] + $votes{$id}) != 0){

$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id})/($values[$db_votes] + $votes{$id});
}
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
print "\tUpdating rating to $values[$db_rating] for link id $id\n";
}

Any ideas?

Cheers,

Mark

Subject Author Views Date
Thread Error:divide by zero Beck 1767 Aug 19, 2001, 8:28 PM
Thread Re: Error:divide by zero
Stealth 1733 Aug 19, 2001, 8:32 PM
Thread Re: Error:divide by zero
Beck 1728 Aug 19, 2001, 8:36 PM
Thread Re: Error:divide by zero
Stealth 1727 Aug 19, 2001, 8:39 PM
Thread Re: Error:divide by zero
Beck 1745 Aug 19, 2001, 8:47 PM
Post Re: Error:divide by zero
Paul 1725 Aug 20, 2001, 5:47 AM