the first thing that one must understand when doing fixed-point arithmetic is that, at the basic level, it is integer arithmetic with some scaling factors applied. perhaps just one scaling factor applied. this scaling factor is directly related to the position of the binary point. unless the chip is a fixed-point DSP or similar, the binary point is implied, not explicit. it, and the associated scaling factor, exists only in the mind of the programmer. the CPU only thinks it is working on integers.
as an example an unsigned, fixed-point, 16-bit format, that i would call "1.15" or, perhaps "Q1.15" (i think the "Q" is superfluous and notation like "Q16" does not supply enough information) has 1 bit to the left of the binary point and 15 bits to the right. but the 16 bits, sitting all by themselves, is an integer. the range of that unsigned integer, $n$, is $0 \le n \le 2^{16}-1$. but the range of the unsigned fixed-point number implied $\hat{n}$ is $0 \le \hat{n} \le 2 - 2^{-15}$ = 1.99996948242188 .
the relationship between the two is:
$$ \hat{n} = n \cdot 2^{-15} $$
or
$$ n = \hat{n} \cdot 2^{15} $$ .
note that the "15"(or "-15") in the exponents is the same as the "15" in the "Q1.15" notation. the scaling factor is directly related to the number of implied bits to the right of the binary point.
if, instead it was a 16-bit signed, we might use "s.15" or "Qs.15" notation to refer to the format, the range of the signed integer $n$ is $-2^{15} \le n \le +2^{15} - 1$. and the range of the implied fixed-point value, $\hat{n}$, is $-1 \le \hat{n} \le 1 - 2^{-15}$ = 0.99996948242188 .
and the mapping between the two is the same as above:
$$ \hat{n} = n \cdot 2^{-15} $$
or
$$ n = \hat{n} \cdot 2^{15} $$ .
the only difference is the use of unsigned int
vs. int
in your C code. they both have the same number of bits to the right of the binary point and they both have the same mapping.
now when C does addition or subtraction or multiplication or division of these values, it is operating on the integer representation of those values. but the integer representation is the same as your implied value, except for the scaling factors.
so if you want to divide some numerator $\hat{n}$ by some denominator $\hat{d}$ to result in some quotient $\hat{q}$, you must first establish what the ranges of all three numbers are. then establish how many bits are to the right of the binary point for each number. then map those numbers $\hat{n}$ and $\hat{d}$ to their integer values $n$ and $d$, and determine what the range of the integer quotient is before it is adjusted to represent $\hat{q}$. there will be a scaling factor that will pop out at you (a power of 2) which will imply shifting of either $n$ or $d$ (most likely $n$) before the integer division is done.