avoid divide by 0 in getting pi simulation value

This commit is contained in:
Brian S. Stephan 2020-10-24 11:56:48 -05:00
parent 4d94322c55
commit 665f56a430
1 changed files with 2 additions and 0 deletions

View File

@ -59,6 +59,8 @@ class PiLog(models.Model):
@property
def value(self):
"""Return this log entry's estimated value of pi."""
if self.total_count == 0:
return 0.0
return 4.0 * int(self.total_count_inside) / int(self.total_count)
@property