/* Factor calibration value into nominal crystal frequency */
/* Measured in parts-per-ten million */
ref_freq += (uint32_t)((double)(correction / 10000000.0) * (double)ref_freq)
Fixed-point is perhaps more precise, using a "long long" aka int64_t:
/* Factor calibration value into nominal crystal frequency */
/* Measured in parts-per-ten million */
ref_freq += (int32_t) ((((((int64_t)correction) << 31) /
10000000LL) * ref_freq) >> 31);
Resulting linked binaries aren't that different in size (depending on optimization level in use).
Your mileage may vary.
From pll_calc():
Fixed-point is perhaps more precise, using a "long long" aka int64_t:
Resulting linked binaries aren't that different in size (depending on optimization level in use). Your mileage may vary.