B
Bruce
<Sorry this question is not tied to C#, but I could not find a good
forum that tackles such questions>
Hi
I am trying to come up with a good hashing function for user IDs in my
app. The user IDs are always of the form 0,1,2,3........
I don't know the total number of users beforehand. I am essentially
trying to write the following method:
// Given a Hash Percent, return 'true' if user ID lies between 0 and
that, 'false' otherwise.
bool IsInRange(int userId, double hashPercent);
So, if 0,1,2,3..199 are fed to this function with hashPercent as 10.5,
the function should return 'true' for 21 users.
I tried out doing some math on the numbers using mod but it did not
work. is there an easy way to do this?
Thanks
Bruce
forum that tackles such questions>
Hi
I am trying to come up with a good hashing function for user IDs in my
app. The user IDs are always of the form 0,1,2,3........
I don't know the total number of users beforehand. I am essentially
trying to write the following method:
// Given a Hash Percent, return 'true' if user ID lies between 0 and
that, 'false' otherwise.
bool IsInRange(int userId, double hashPercent);
So, if 0,1,2,3..199 are fed to this function with hashPercent as 10.5,
the function should return 'true' for 21 users.
I tried out doing some math on the numbers using mod but it did not
work. is there an easy way to do this?
Thanks
Bruce