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.

IQmath needs a function to convert an IQ number between different IQN format

Hi,

There are IQNtoIQ and IQtoIQN functions in IQmath, but sometimes we need to convert 

an IQ number between different IQN format, not just between IQN and the GLOVAL_Q format.

If we use IQNtoIQ and IQtoIQN to convert, it may cause overflow or underflow. So normally

we use left shift or right shift to convert the IQ number. Certainly this way doesn't work if we set

MATH_TYPE to 1 (floating point).

It is very helpful if we have a function like IQMtoIQN that has the following definition:

#if (MATH_TYPE==IQ_MATH)

#if (M > N)

#define IQMtoIQN(a) ((a) >> (M - N))

#else 

#define IQMtoIQN(a) ((a) << (N - M))

#endif

#else 

#define IQMtoIQN(a) (a)

#endif

or we can use a general format:

#if (MATH_TYPE==IQ_MATH)

#define IQNshift(a, M) ((M >= N) ? ((a) >> (M - N)) : ((a) << (N - M)))

#else 

#define IQNshift(a, M) (a)

#endif 

thanks,

Jiakai