Caculating 1/d if you have multiply

  • Thread starter Thread starter rcgldr
  • Start date Start date
AI Thread Summary
The discussion focuses on implementing an unsigned integer multiplication algorithm in assembly code, specifically multiplying 32-bit integers to produce a 64-bit result. The algorithm aims to compute the reciprocal of a number D using an iterative method that starts with an estimated quotient from a table, achieving 8 bits of precision. The iterative formula used is q_{n+1} = q_n(2 - q_n * X), where q_0 is the initial estimate. The process involves pre and post shifting of values, typically requiring only 4 to 5 iterations to achieve 32 bits of precision. The conversation also raises the question of whether there are more efficient algorithms available for this task.
rcgldr
Homework Helper
Messages
8,923
Reaction score
675
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.

q_0\ =\ eq

q_{n+1}\ =\ q_n\ (2\ -\ q_n\ X)

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:
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
30
Views
6K
Replies
12
Views
3K
Replies
6
Views
3K
Replies
11
Views
3K
Replies
1
Views
2K
Replies
7
Views
3K
Replies
1
Views
2K
Back
Top