diff --git a/src/tags.cpp b/src/tags.cpp index 8d8b9c42..fcedb5de 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -2463,22 +2463,23 @@ namespace Exiv2 { std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*) { - Rational t = value.toRational(); - if (t.first > 1 && t.second > 1 && t.second >= t.first) { - t.second = static_cast( - static_cast(t.second) / t.first + 0.5); - t.first = 1; + if (value.count() == 0) return os; + if (value.typeId() != unsignedRational) return os << "(" << value << ")"; + + URational t = value.toRational(); + if (t.first == 0 || t.second == 0) { + os << "(" << t << ")"; } - if (t.second > 1 && t.second < t.first) { - t.first = static_cast( - static_cast(t.first) / t.second + 0.5); - t.second = 1; + else if (t.second == t.first) { + os << "1 s"; } - if (t.second == 1) { - os << t.first << " s"; + else if (t.second % t.first == 0) { + t.second = t.second / t.first; + t.first = 1; + os << t << " s"; } else { - os << t.first << "/" << t.second << " s"; + os << static_cast(t.first) / t.second << " s"; } return os; }