Skip to content

Commit

Permalink
Merge pull request #1513 from brave/weight-fix-60
Browse files Browse the repository at this point in the history
Fixes weights in normalize process
  • Loading branch information
NejcZdovc authored Jan 30, 2019
2 parents 6e74647 + 2766a12 commit 509368a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions vendor/bat-native-ledger/src/bat_publishers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,17 @@ void BatPublishers::synopsisNormalizerInternal(
std::vector<double> roundoffs;
unsigned int totalPercents = 0;
for (size_t i = 0; i < list.size(); i++) {
realPercents.push_back((double)list[i].score / (double)totalScores * 100.0);
percents.push_back((unsigned int)std::lround(realPercents[realPercents.size() - 1]));
double roundoff = percents[percents.size() - 1] - realPercents[realPercents.size() - 1];
double floatNumber = (list[i].score / totalScores) * 100.0;
double roundNumber = (unsigned int)std::lround(floatNumber);
realPercents.push_back(floatNumber);
percents.push_back(roundNumber);
double roundoff = roundNumber - floatNumber;
if (roundoff < 0.0) {
roundoff *= -1.0;
}
roundoffs.push_back(roundoff);
totalPercents += percents[percents.size() - 1];
weights.push_back((double)list[i].score / (double)list.size() * 100.0);
totalPercents += roundNumber;
weights.push_back(floatNumber);
}
while (totalPercents != 100) {
size_t valueToChange = 0;
Expand Down

0 comments on commit 509368a

Please sign in to comment.