Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Q-format macros

group qfmt_macros

  Defines

  F(N)

    Convert fixed-point value to double-precision float.

    This macro is meant to allow for parameterized access to the more specific conversion macros, such as `F8()`, `F24()`, `F31()` and so on. Being parameterized allows the user to specify the Q-format (fractional bit count) using another macro. For example:

        #define X_FRAC_BITS   24
        int32_t x = ...;
        ...
        // Convert x to double
        double dbl_x = F(X_FRAC_BITS)(x);

  Q(N)

    Convert floating-point value to fixed-point value.

    This macro is meant to allow for parameterized access to the more specific conversion macros, such as `Q8()`, `Q24()`, `Q31()` and so on. Being parameterized allows the user to specify the Q-format (fractional bit count) using another macro. For example:

        #include <math.h>
        ...
        #define PI_FRAC_BITS   24
        int32_t x = Q(PI_FRAC_BITS)(M_PI);

  Q31(f)

    Convert `double` value to Q1.31 fixed-point value, with rounding.

  Q30(f)

    Convert `double` value to Q2.30 fixed-point value, with rounding.

  Q29(f)

    Convert `double` value to Q3.29 fixed-point value, with rounding.

  Q28(f)

    Convert `double` value to Q4.28 fixed-point value, with rounding.

  Q27(f)

    Convert `double` value to Q5.27 fixed-point value, with rounding.

  Q26(f)

    Convert `double` value to Q6.26 fixed-point value, with rounding.

  Q25(f)

    Convert `double` value to Q7.25 fixed-point value, with rounding.

  Q24(f)

    Convert `double` value to Q8.24 fixed-point value, with rounding.

  Q23(f)

    Convert `double` value to Q9.23 fixed-point value, with rounding.

  Q22(f)

    Convert `double` value to Q10.22 fixed-point value, with rounding.

  Q21(f)

    Convert `double` value to Q11.21 fixed-point value, with rounding.

  Q20(f)

    Convert `double` value to Q12.20 fixed-point value, with rounding.

  Q19(f)

    Convert `double` value to Q13.19 fixed-point value, with rounding.

  Q18(f)

    Convert `double` value to Q14.18 fixed-point value, with rounding.

  Q17(f)

    Convert `double` value to Q15.17 fixed-point value, with rounding.

  Q16(f)

    Convert `double` value to Q16.16 fixed-point value, with rounding.

  Q15(f)

    Convert `double` value to Q17.15 fixed-point value, with rounding.

  Q14(f)

    Convert `double` value to Q18.14 fixed-point value, with rounding.

  Q13(f)

    Convert `double` value to Q19.13 fixed-point value, with rounding.

  Q12(f)

    Convert `double` value to Q20.12 fixed-point value, with rounding.

  Q11(f)

    Convert `double` value to Q21.11 fixed-point value, with rounding.

  Q10(f)

    Convert `double` value to Q22.10 fixed-point value, with rounding.

  Q9(f)

    Convert `double` value to Q23.9 fixed-point value, with rounding.

  Q8(f)

    Convert `double` value to Q24.8 fixed-point value, with rounding.

  F31(x)

    Convert Q1.31 fixed-point value to `double` value.

  F30(x)

    Convert Q2.30 fixed-point value to `double` value.

  F29(x)

    Convert Q3.29 fixed-point value to `double` value.

  F28(x)

    Convert Q4.28 fixed-point value to `double` value.

  F27(x)

    Convert Q5.27 fixed-point value to `double` value.

  F26(x)

    Convert Q6.26 fixed-point value to `double` value.

  F25(x)

    Convert Q7.25 fixed-point value to `double` value.

  F24(x)

    Convert Q8.24 fixed-point value to `double` value.

  F23(x)

    Convert Q9.23 fixed-point value to `double` value.

  F22(x)

    Convert Q10.22 fixed-point value to `double` value.

  F21(x)

    Convert Q11.21 fixed-point value to `double` value.

  F20(x)

    Convert Q12.20 fixed-point value to `double` value.

  F19(x)

    Convert Q13.19 fixed-point value to `double` value.

  F18(x)

    Convert Q14.18 fixed-point value to `double` value.

  F17(x)

    Convert Q15.17 fixed-point value to `double` value.

  F16(x)

    Convert Q16.16 fixed-point value to `double` value.

  F15(x)

    Convert Q17.15 fixed-point value to `double` value.

  F14(x)

    Convert Q18.14 fixed-point value to `double` value.

  F13(x)

    Convert Q19.13 fixed-point value to `double` value.

  F12(x)

    Convert Q20.12 fixed-point value to `double` value.

  F11(x)

    Convert Q21.11 fixed-point value to `double` value.

  F10(x)

    Convert Q22.10 fixed-point value to `double` value.

  F9(x)

    Convert Q23.9 fixed-point value to `double` value.

  F8(x)

    Convert Q24.8 fixed-point value to `double` value.