For soft rollouts of new features, I want my server which holds the feature flags to return a percentage number, and then have the client figure out which side of the percentage it is on. I want to use the user-id to make this choice consistently, so that an individual user will always see the same side of the flag.
I've gotten as far as
(crypto.createHash('md5').update(userID).digest('hex').charCodeAt(0)
Which hashes the ID(which will be some large string), then takes the first character of the hash and converts it to an integer id. Unfortunately that number seems to not be a random distribution, so even if I shift and multiply it so that it is always between 0 and 100, it doesn't seem randomly even. Here are some hashes of random strings I ran:
checking 25
15.2
checking 26
96.89999999999999
checking 27
98.8
checking 28
13.299999999999999
checking 29
15.2
checking 30
102.6
checking 31
15.2
checking 32
7.6
checking 33
102.6
checking 34
15.2
checking 35
102.6
checking 36
15.2
checking 37
7.6
checking 38
96.89999999999999
checking 39
96.89999999999999
checking 40
7.6
checking 41
100.69999999999999
checking 42
13.299999999999999
checking 43
96.89999999999999
checking 44
93.1
checking 45
96.89999999999999
checking 46
1.9
checking 47
15.2
checking 48
Is there a better way to do this check so that it creates a random distribution of percentages?