diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:03 +0200 |
| commit | 059831534c7e884f0a607ed86b582fd00d821731 (patch) | |
| tree | 76bcb67a78f8aa2654fd34c2ad801a62136b0170 /Radio.cpp | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'Radio.cpp')
| -rw-r--r-- | Radio.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -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<Frequency>::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<double>(std::numeric_limits<Frequency>::max ())) - { - value = 0.; - *ok = false; - } - else - { - *ok = true; - } + return 0; } - return std::llround (value); + return static_cast<Frequency> (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<double>(std::numeric_limits<Frequency>::min ()) - || value > static_cast<double>(std::numeric_limits<Frequency>::max ())) + if (value < static_cast<double>(std::numeric_limits<FrequencyDelta>::min ()) + || value > static_cast<double>(std::numeric_limits<FrequencyDelta>::max ())) { value = 0.; *ok = false; |
