Depending on the number of colors you're looking for, why not try using bitwise operators (PHP's reference here, since you mentioned it in the question) to reduce the number of significant digits? You could round the RGB values before shifting to increase accuracy as well.