Re: 32 bit fixed point division



>>#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
.



Relevant Pages

  • Re: [VW] How can image be saved automicly?
    ... should do the trick. ... Regards, ... Randy ... Prev by Date: ...
    (comp.lang.smalltalk)
  • Replication between domains?
    ... they are in the same forest? ... Regards, ... Randy. ... Prev by Date: ...
    (microsoft.public.windowsxp.help_and_support)
  • Replication accross Domains?
    ... they are in the same forest? ... Regards, ... Randy. ... Prev by Date: ...
    (microsoft.public.sqlserver.replication)
  • Re: infinity
    ... Randy wrote: ... element of the original set? ... Regards ... Prev by Date: ...
    (sci.math)
  • Re: Simplify searching
    ... Thank you Randy. ... Regards ... > dim ABC ... > dim ABnotC ...
    (microsoft.public.vb.general.discussion)