This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSPLIB ldiv16 function



Hi,

I have some difficulties to use the ldiv16 function, specially with a small numerator.

The ldiv16 function takes a numerator N in Q.31and a denominator D in Q.15. However, I use the function for getting the result of N/D where N and D are integers reciprocally in 32 bits and 16 bits ie:

(N/2^31) / (D/2^15) = (N/D) / 2^16 and the ldiv16 gives as result N/D in Q.15 = (N/D)/2^15

=> N/D = ldiv16(&N, &D, &r, &rexp, 1)*2

For example, I try to compute 95495/2 :

ldiv16(95495, 2, &r, &rexp, 1) -> I get as result 15681; this is a wrong result (95495/2 = 47748*2)

But when I try 267386880/2, I get the correct result 66836480 (267386880/2 = 66836480 *2).

Can anybody clarify me the limit of ldiv16 function or explain what is wrong on my use of ldiv1- function ?

Thanks for help.

Diane Lim