RGBConverter
RGBConverter copied to clipboard
Integer division rounding to zero in hue2rgb
Hi, I needed an HSL to RGB converter and was really excited to find this. However, when I started to use your library in my arduino project I kept getting grey values, as if my saturation was zero. After some digging I realized the cause of the issue was in the hue2rgb function in the cpp file - it would always fail the if statements with fractions and return p. This is because the integer division was rounding to zero. If you change the fractions from 1/2 to 1/2.0 this problem goes away and the converter works as it should!
True, that is why I recommend to always add a "." after each number when you are working with floating point numbers so that stuff like this doesn't happen.
Has this issue been resolved? I see https://github.com/ratkins/RGBConverter/blob/master/RGBConverter.cpp#L166 has a 1/2.0
instead of 1/2
so this fix has been incorporated?
Can this issue be closed?
As noted in the main README I consider this abandoned. Feel free to fork your own and fix it there.
OK, will do, thanks.