Xilinx/Vitis-HLS-Introductory-Examples

truncate toward to zero

kimstik opened this issue · 3 comments

hamming_window.c

C++ on casting float to integer truncate toward to 0 here:
rom_array[i] = (int16_t)(WIN_COEFF_SCALE * real_val);

Guess that correct rounding should be applied instead.
hamm

According to C++ rules, a C-style cast to an integer of a float value will result in the truncation of the value and the digits to the right of the decimal point are ignored.

@ramanan-radhakrishnan
C++ on casting float to integer truncate toward to 0. This is behavior according to C++.
I don’t think we should rely on it to calculate the coefficients for windows. We are talking about the numerically correct hamming windowing implementation.

@ravicho
It was excellent example
What is the reason to drop it?

eb18e89

Hi @kimstik,

Okay - we will add a call to round before the cast to integer to achieve the desired result.

The example will be back soon. Good to hear feedback that it was a good example. It will be updated and brought back soon.