Skip to content

Commit ab6bc66

Browse files
singalsulgirdwood
authored andcommitted
Audio: Format: Add macro to convert fraction to double
The usage of Q_CONVERT_QTOF() causes build issue with llvm toolchain when assigned to a double type in ztest code: error: implicit conversion increases floating-point precision: 'float' to 'double' [-Werror,-Wdouble-promotion] Since a double is needed to fully match the accuracy of 32 bit fraction, a new macro Q_CONVERT_QTOD() is added for the purpose. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent adbd6e7 commit ab6bc66

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/include/sof/audio/format.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
/* Convert fractional Qnx.ny number x to float */
7171
#define Q_CONVERT_QTOF(x, ny) ((float)(x) / ((int64_t)1 << (ny)))
7272

73+
/* Convert fractional Qnx.ny number x to double */
74+
#define Q_CONVERT_QTOD(x, ny) ((double)(x) / ((int64_t)1 << (ny)))
75+
7376
/* A more clever macro for Q-shifts */
7477
#define Q_SHIFT(x, src_q, dst_q) ((x) >> ((src_q) - (dst_q)))
7578
#define Q_SHIFT_RND(x, src_q, dst_q) \

0 commit comments

Comments
 (0)