summaryrefslogtreecommitdiff
path: root/Radio.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
commit059831534c7e884f0a607ed86b582fd00d821731 (patch)
tree76bcb67a78f8aa2654fd34c2ad801a62136b0170 /Radio.cpp
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'Radio.cpp')
-rw-r--r--Radio.cpp21
1 files changed, 8 insertions, 13 deletions
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<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;