/**
 * @file q_demo.c
 * @brief Multiply two application values using Q4.28 arithmetic, C99.
 * @copyright SPDX-License-Identifier: MIT
 */

#include "fl_q.h"
#include <inttypes.h>
#include <stdio.h>

/**
 * @brief Convert, multiply and print a raw Q value and its application value.
 * @return Zero after writing the result to standard output.
 */
int main(void)
{
    const fl_q_format_t q = {32u, 28u};
    const int32_t input = fl_q_from_double(0.5, q);
    const int32_t gain = fl_q_from_double(0.25, q);
    const int32_t output = fl_q_mul(input, gain, q);

    printf("%" PRId32 " %.17g\n", output, fl_q_to_double(output, q));
    return 0;
}
