avoid divide by 0 in getting pi simulation value
This commit is contained in:
parent
4d94322c55
commit
665f56a430
@ -59,6 +59,8 @@ class PiLog(models.Model):
|
|||||||
@property
|
@property
|
||||||
def value(self):
|
def value(self):
|
||||||
"""Return this log entry's estimated value of pi."""
|
"""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)
|
return 4.0 * int(self.total_count_inside) / int(self.total_count)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user