In the above code, conversion from RGB to HEX and then from HEX to RGB does
not give us the same output. This issue is very typical of any programming
language where we are dealing with float calculations. So you should use
some rounding logic if you want to compare it with original color
In case of conversion to HEX, we usually round the floats to nearest
integers with default `round` function.
However, our benchmarks and testing suggest that these values are accurate
with an error of '0.001'. We also check this during our testings. This much
precision should be good enough for most of the cases. In case, you want even
better precision, we kindly ask you to implement the method by yourself
instead of a depending method provided by `SecretColors`. In future,
we plan to take a look at this in more details. But for now,
the workaround is to make some rounding function like following
python
Use precision for rounding according to your need
def rounded_rgb(*args):
return tuple(round(x,2) for x in args)