Machine-translated by Google. Questions are authored in English.
Top

Discussion

What does this compute, with a and b in Q15?

int32_t p = ((int32_t)a * b) >> 15;

  • A.their sum, scaled by 32768
  • B.their quotient in Q15 format
  • C.their product, also in Q15
  • D.their product in Q30, the shift having no effect

Answer: C

The cast widens the multiplication to thirty-two bits so no precision is lost, and the shift removes the extra fifteen fractional bits. Omitting the cast is the usual bug, since the multiplication would then be done in sixteen bits and overflow.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.