I need a way to compute how many times a fixed point number B is contained into a fixed point number A. Something like integer division but on non-integer operands. I need to design an hardware block for this operation. My first guess is to use division as shift and subtract and stop when I reach the fractional part but maybe you know better ways to find it.
Asked
Active
Viewed 195 times
1 Answers
0
If I understand you correctly you want the integer part of the fractional division, i.e.
C = floor(A / B)
Now, fractional division is not any different than integer division, besides adjusting the decimal point, if you represent A = a * 2^-n
and B = b * 2^-m
you get
C = floor(A / B) = floor((a / b) * 2^(-n-m))
So you can use the division algorithm for integers (which is essentially shift and subtract) unchanged and ignore (round down) the least significant n+m
bits, or more efficiently just stop iterating once you've reached the decimal point.

mbschenkel
- 1,865
- 1
- 18
- 40