From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- Radio.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'Radio.cpp') diff --git a/Radio.cpp b/Radio.cpp index 5ee29040..f7fcd06d 100644 --- a/Radio.cpp +++ b/Radio.cpp @@ -52,19 +52,14 @@ namespace Radio Frequency frequency (double value, int scale, bool * ok) { value *= std::pow (10., scale); - if (ok) + auto const exclusive_frequency_limit = std::ldexp (1., std::numeric_limits::digits); + auto const valid = std::isfinite (value) && value >= 0. && value < exclusive_frequency_limit; + if (ok) *ok = valid; + if (!valid) { - if (value < 0. || value > static_cast(std::numeric_limits::max ())) - { - value = 0.; - *ok = false; - } - else - { - *ok = true; - } + return 0; } - return std::llround (value); + return static_cast (std::round (value)); } FrequencyDelta frequency_delta (QVariant const& v, int scale, bool * ok, QLocale const& locale) @@ -91,8 +86,8 @@ namespace Radio value *= std::pow (10., scale); if (ok) { - if (value < static_cast(std::numeric_limits::min ()) - || value > static_cast(std::numeric_limits::max ())) + if (value < static_cast(std::numeric_limits::min ()) + || value > static_cast(std::numeric_limits::max ())) { value = 0.; *ok = false; -- cgit v1.2.3