3.11.8 Q15_MULTIPLY Macro

C

#define   Q15_MULTIPLY(x, y )   (int16_t)(( (int32_t)(x)  * (int32_t)(y)) >> 15U )

Summary

Performs multiplication of two fixed-point numbers represented in Q15 format.

Description

This macro performs multiplication of two fixed-point numbers represented in Q15 format. Q15 is a common fixed-point representation where a 16-bit signed integer is used to represent a value between -1 and 1. The result of the multiplication is also a Q15 formatted value.

Example

int16_t a = 16384;  // This is 0.5 in Q15 format
int16_t b = 16384;  // This is 0.5 in Q15 format

int16_t result = Q15_MULTIPLY(a, b);  
    

Remarks

None