Caculating 1/d if you have multiply

  • Thread starter Thread starter rcgldr
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
0 replies · 2K views
Messages
8,947
Reaction score
687
This will be done in assembly code, using an integer multiply, 32 bit by 32 bit producing 64 bit result. Unsigned algorithm is good enough.


Generic algorithm to find 1 / D, eq is initial estimated quotient, from table, say with 8 bits of precision.

[tex]q_0\ =\ eq[/tex]

[tex]q_{n+1}\ =\ q_n\ (2\ -\ q_n\ X)[/tex]

For integer math, pre and post shifting of values will be done. Generally only 4 or 5 interations are required to get 32 bits of precision.

Are there better algorithms?
 
Last edited: