FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
New since the initial 10.0 release.

hash-primify

Arguments: int

Returns a positive fixnum suitable for a hash-table size greater than or equal to int, which should be a fixnum. With all fixnums below the limit, the value returned will be a prime number. The value is returned from a table, so the calculation is fast. For fixnums above the limit, the value returned is at least not divisible by 2, 3, 5, or 7. Results lose accuracy as they approach most-positive-fixnum.

Limits:

Limits are approximate, and may change in the future. Currently:

Granularity:

Not all prime numbers are returned. The prime number table is populated with an approximately 2% increment, so the difference between one result and the next possible result (for values of int under the limit) are approximately 2% apart:

cl-user(1): (excl:hash-primify 100000000)
100121387
cl-user(2): (excl:hash-primify (1+ *))
102123817
cl-user(3): (float (/ * **))
1.02
cl-user(4): 

There may be other prime numbers not returned by this function; but because it is the goal of this function to quickly return a size suitable for efficient hash-table operation, populating all primes is not necessary.


Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page is new in the 10.0 release.
Created 2016.6.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.0
New since the initial 10.0 release.