cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
anoir.nechi
Observer
Observer
504 Views
Registered: ‎08-31-2018

Error when using modulus operator with floats

Jump to solution

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?

0 Kudos
1 Solution

Accepted Solutions
calibra
Scholar
Scholar
494 Views
Registered: ‎06-20-2012

Operator % is only for integer.

For float use function

Hu = fmod(60 * ((gn - bn) / diff),6))

 

== If this was helpful, please feel free to give Kudos, and close if it answers your question ==

View solution in original post

1 Reply
calibra
Scholar
Scholar
495 Views
Registered: ‎06-20-2012

Operator % is only for integer.

For float use function

Hu = fmod(60 * ((gn - bn) / diff),6))

 

== If this was helpful, please feel free to give Kudos, and close if it answers your question ==

View solution in original post