Re: 32 bit fixed point division
- From: "sbhavikb" <sbhavikb@xxxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 07:39:03 -0500
>>#include <stdint.h>
>>
>>uint64_t Divide32(uint32_t y, uint32_t x)
>>{
>> uint16_t n;
>> uint64_t answer;
>> uint64_t remainder;
>> uint64_t divisor;
>>
>> answer = 0;
>> remainder = x;
>> divisor = (uint64_t)y << 32;
>>
>> for (n = 0; n < 32; n++)
>> {
>> divisor = divisor >> 1;
>> if (remainder >= divisor)
>> {
>> remainder -= divisor;
>> answer |= (uint64_t)1 << (63 - n);
>> }
>> }
>>
>> for (n = 0; n < 32; n++)
>> {
>> remainder = remainder << 1;
>> if (remainder >= divisor)
>> {
>> remainder -= divisor;
>> answer |= (uint64_t)1 << (31 - n);
>> }
>> }
>>
>> return answer;
>>}
>>
>>
>
>Hi Randy,
>Thank you very much for this wonderful code. It minimised my problem to
a
>great extent.
>
>Thanks again,
>
>Regards
>bd.
>
>
>This message was sent using the Comp.DSP web interface on
>www.DSPRelated.com
>
Hay, can anyone please give a code for 32 bit fixed point division which
would work for a 32 bit DSP processor. It looks like this code will not
work, as it involves working with a 64 bit integer.
Thanks and Regards,
SB.
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
.
- Follow-Ups:
- Re: 32 bit fixed point division
- From: rhnlogic@xxxxxxxxx
- Re: 32 bit fixed point division
- References:
- Re: 32 bit fixed point division
- From: Randy Yates
- Re: 32 bit fixed point division
- From: bsdap
- Re: 32 bit fixed point division
- Prev by Date: Re: Electrical Engineering Careers in USA
- Next by Date: Location of malloc function
- Previous by thread: Re: 32 bit fixed point division
- Next by thread: Re: 32 bit fixed point division
- Index(es):
Relevant Pages
|