Fix roundings with lround()
This commit is contained in:
committed by
Jonas Kvinge
parent
d5b0794b00
commit
1a967597e8
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QApplication>
|
||||
#include <QObject>
|
||||
@@ -539,7 +541,7 @@ QString RatingItemDelegate::displayText(const QVariant &value, const QLocale&) c
|
||||
if (value.isNull() || value.toDouble() <= 0) return QString();
|
||||
|
||||
// Round to the nearest 0.5
|
||||
const double rating = double(int(value.toDouble() * RatingPainter::kStarCount * 2 + 0.5)) / 2;
|
||||
const double rating = double(lround(value.toDouble() * RatingPainter::kStarCount * 2)) / 2;
|
||||
|
||||
return QString::number(rating, 'f', 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user