summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-06-05 13:47:18 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-06-05 14:00:05 +0200
commit2431e200b9c80a5039485a4b228cd829b43ac082 (patch)
tree41752a91af8b1d28695c743a2ac5e154f92f8f83 /src/util
parent1fbde1129346c420798786194a30abd68209f9a0 (diff)
Account for rounding errors when casting quint64 to double
Diffstat (limited to 'src/util')
-rw-r--r--src/util/duration.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/util/duration.cpp b/src/util/duration.cpp
index 17e1d25383..5189447b92 100644
--- a/src/util/duration.cpp
+++ b/src/util/duration.cpp
@@ -27,7 +27,8 @@ QChar DurationBase::kDecimalSeparator = QChar(0x002E);
// static
QString DurationBase::formatTime(double dSeconds, Precision precision) {
if (dSeconds < 0.0 || !isfinite(dSeconds)
- || dSeconds > std::numeric_limits<qint64>::max()) {
+ // Use >= instead of >: 2^63-1 (qint64) is rounded to 2^63 (double)
+ || dSeconds >= static_cast<double>(std::numeric_limits<qint64>::max())) {
// negative durations and infinity or isNaN values are not supported
return kInvalidDurationString;
}