Technical discussions related to Audio Signal Processing (digital effects, acoustics, noise reduction, musical signal processing, etc).
Hello All, Can anyone please help me in writing a C code for dividing a 32 bit fixed point number by another 32 bit number? I already have a code which works fine for 16 bit (div_s) but it can not be converted to 32 bit. So please give me some source code or algorithm for implementing 32 bit division. I am intending to make this code as platform independent. Thanks and Regards, bd.
You can use Newton-Raphson method of successive approximation. The estimate Y (reciprocal of X) is calculated as : Y = 2*Y - (Y^2 * Xn); where Xn = norm(X) With a good initial estimate of Y, you should be able to get the solution within 5-6 iterations for a 32-bit. -Bhagawan bsdap <bsdap@bsda...> wrote: Hello All, Can anyone please help me in writing a C code for dividing a 32 bit fixed point number by another 32 bit number? I already have a code which works fine for 16 bit (div_s) but it can not be converted to 32 bit. So please give me some source code or algorithm for implementing 32 bit division. I am intending to make this code as platform independent. Thanks and Regards, bd.
Thanks for the suggestions, I tried implementing this formula but found that due to repetitive fixed point multiplication the distortion is high and the accuracy is hampered. Have any one implemented this? Is there any other method by which this can be done. Thanks again for the reply..Please give more suggestions... Thanks and Regards, bd. bhagawan reddy <bhagawan007@bhag...> wrote:You can use Newton-Raphson method of successive approximation. The estimate Y (reciprocal of X) is calculated as : Y = 2*Y - (Y^2 * Xn); where Xn = norm(X) With a good initial estimate of Y, you should be able to get the solution within 5-6 iterations for a 32-bit. -Bhagawan bsdap <bsdap@bsda...> wrote: Hello All, Can anyone please help me in writing a C code for dividing a 32 bit fixed point number by another 32 bit number? I already have a code which works fine for 16 bit (div_s) but it can not be converted to 32 bit. So please give me some source code or algorithm for implementing 32 bit division. I am intending to make this code as platform independent. Thanks and Regards, bd.
I implemented this formula long time back and was able to get acccurate results. I don't remeber the initial estimate. Please try to increas the iterations and check for accuracy. The answer you get, should be formulated in this way : Out of Y = 2*Y - (Y^2 * Xn); you get Yfrac (fractional part of result) On calculation norm(x) , you get Yexp(exponent part of result) Actual result (Reciprocal of 1/X) = Yfrac *(2^Yexp) bsdap <bsdap@bsda...> wrote: Thanks for the suggestions, I tried implementing this formula but found that due to repetitive fixed point multiplication the distortion is high and the accuracy is hampered. Have any one implemented this? Is there any other method by which this can be done. Thanks again for the reply..Please give more suggestions... Thanks and Regards, bd. bhagawan reddy wrote:You can use Newton-Raphson method of successive approximation. The estimate Y (reciprocal of X) is calculated as : Y = 2*Y - (Y^2 * Xn); where Xn = norm(X) With a good initial estimate of Y, you should be able to get the solution within 5-6 iterations for a 32-bit. -Bhagawan bsdap wrote: Hello All, Can anyone please help me in writing a C code for dividing a 32 bit fixed point number by another 32 bit number? I already have a code which works fine for 16 bit (div_s) but it can not be converted to 32 bit. So please give me some source code or algorithm for implementing 32 bit division. I am intending to make this code as platform independent. Thanks and Regards, bd.