> On Feb 12, 2015, at 9:21 AM, Warren Young <w...@etr-usa.com> wrote:
> 
>   d = log2(n^2 / 2p) / 4

In C:

   double n = num_artifacts;
   double p = acceptable_probability_of_collision;
   assert(p < 0.002);
   int d = ceil(log2((n * n) / (2 * p)) / 4.0);

n needs to be a double because squaring 5 and 6 digit numbers gets you into 
scientific notation territory.  We don’t want to require 64-bit ints to get the 
correct answer, and we need to do FP math with the result anyway.

We should use ceil() instead of round() because we need to calculate the 
smallest number of digits that *exceeds* our requested probability of 
collision.  Going back to my 97,000 hash repository example, we need 14 digits 
to do that, not 13.
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to