Skip to content

Commit

Permalink
Fix the nan error in percentage #122
Browse files Browse the repository at this point in the history
  • Loading branch information
brung committed Feb 25, 2015
1 parent c85d3b0 commit 7d2f609
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion unnamed/DetailAnswerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)awakeFromNib {
- (void)layoutSubviews {
self.answerIndexLabel.text = [NSString stringWithFormat:@"%ld.", (long)self.answer.index +1];
self.answerLabel.text = self.answer.text;
float percent = (float)self.answer.count / (float)self.totalVotes;
float percent = self.totalVotes > 0 ? (float)self.answer.count / (float)self.totalVotes : 0;
self.percentLabel.text = [NSString stringWithFormat:@"%.1f%%", percent * 100];
self.barGraph.percent = percent;
}
Expand Down

0 comments on commit 7d2f609

Please sign in to comment.