mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-04 14:07:30 +00:00
Fix fractional calculation for frequencies close to integer multiples
This commit is contained in:
parent
b3cc97c0c9
commit
e0c9f4dcee
2 changed files with 12 additions and 2 deletions
|
|
@ -190,6 +190,14 @@ bool MAX2871::SetFrequency(uint64_t f) {
|
|||
|
||||
auto approx = Algorithm::BestRationalApproximation(fraction, 4095);
|
||||
|
||||
if (approx.denom == approx.num) {
|
||||
// got an impossible result due to floating point limitations(?)
|
||||
// Set fractional part to zero, increase integer part instead
|
||||
approx.num = 0;
|
||||
approx.denom = 2;
|
||||
N++;
|
||||
}
|
||||
|
||||
if(approx.denom == 1) {
|
||||
// M value must be at least 2
|
||||
approx.denom = 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue