Upcast to uint64 to avoid overflow

This commit is contained in:
Reed Nightingale 2020-02-11 23:24:37 -08:00
parent 77fffccb46
commit 23ecb4e4b2

View File

@ -104,7 +104,7 @@ uint32_t getFreqInBand(const uint32_t frequency,
memcpy_P(&target_band,&bands[target_band_index],sizeof(target_band));
const uint32_t range_current = current_band.max - current_band.min;
const uint32_t range_target = target_band.max - target_band.min;
return (((frequency - current_band.min) * range_target / range_current + target_band.min)/100)*100;//truncated 100Hz
return (((frequency - current_band.min) * (uint64_t)range_target / range_current + target_band.min)/100)*100;//truncated 100Hz
}
}