Mercurial > minori
comparison src/core/anime.cc @ 186:6ef31dbb90ca
anime: no unnecessary conversion to floating point
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 06 Dec 2023 11:47:59 -0500 |
parents | 62e336597bb7 |
children | 975a3f0965e2 |
comparison
equal
deleted
inserted
replaced
185:62e336597bb7 | 186:6ef31dbb90ca |
---|---|
47 const int score = list_info_->score; | 47 const int score = list_info_->score; |
48 if (score == 0) | 48 if (score == 0) |
49 return ""; | 49 return ""; |
50 | 50 |
51 switch (session.config.anime_list.score_format) { | 51 switch (session.config.anime_list.score_format) { |
52 case ScoreFormat::POINT_10_DECIMAL: { | 52 case ScoreFormat::POINT_10_DECIMAL: |
53 std::ostringstream out; | 53 return std::to_string(score / 10) + "." + std::to_string(score % 10); |
54 out.precision(1); | |
55 out << std::fixed << (static_cast<double>(score) / 10); | |
56 return std::move(out).str(); | |
57 } | |
58 case ScoreFormat::POINT_10: | 54 case ScoreFormat::POINT_10: |
59 return std::to_string(score / 10); | 55 return std::to_string(score / 10); |
60 case ScoreFormat::POINT_5: { | 56 case ScoreFormat::POINT_5: { |
61 std::string stars = ""; | 57 std::string stars = ""; |
62 | 58 |