PYNQ: PYTHON PRODUCTIVITY

Error when using modulus operator with floats

I am trying to generate an IP converting an RGB image to HSV I followed the theory and I implemented the code and I got this error:

ERROR: [HLS 200-70] Compilation errors found: In file included from 
img_proc/converter.cpp:1:
img_proc/converter.cpp:30:44: error: invalid operands to binary expression ('float' and 'float')
         Hu = (60 * ((gn - bn) / diff) % 6);
               ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~

Knowing that gn, bn, and diff are already floats.

Why am I getting this problem?

How can I fix this?

The C language does not define the % operator for floating point numbers - see this StackOverflow thread for more details. The solution given there is to use the fmod or remainder standard library functions instead. Both of these are supported by HLS.

Peter