AnthonyWhitakerJr / WFReliquary

Companion app for Warframe game. Allows users to anticipate results of fissure missions.
1 stars 1 forks source link

Add a single decimal place to reward drop % #3

Closed AnthonyWhitakerJr closed 8 years ago

AnthonyWhitakerJr commented 8 years ago

When displaying drop percentage for rewards, display a single number after the decimal iff it is significant.

25.3% - YES 2% - YES 2.0% - NO

AnthonyWhitakerJr commented 8 years ago

Accomplished with: let odds = reward.dropOdds!100 let oddsString = odds.truncatingRemainder(dividingBy: 1) == 0 ? "(Int(round(odds)))%" : "(round(odds \ 10) / 10)%"

Considered String.format but if we are going to need rounding anyway, may as well do it like this.