> > > > + > > > > + df_quotient = df / m; > > > > + df_remainder = ((df % m) * 1000) / m; > > > > + > > > > + if (freq > df_quotient) { > > > > + df_quotient = freq - df_quotient - 1; > > > > + df_remainder = 1000 - df_remainder; > > > > > > Where does 1000 come from? > > > > 1000 is come from "borrow 1" in last operation. > > It's scaling the value right? What is being scaled? Are we converting > units to Hz from kHz? Here just using integer replacement floating point operation, for example: df = 13, m = 3 13 / 3 = 4.33333333 df_quotient = 4 df_remainder = 0.3333333 * 1000 (accurate to 3 decimal places) = 333