> The minimum size (in bits) that you'll need to store the object is:

   Got it. But what is the formula for storing the numbers?

Conceptually:

        Dim numbers() as Integer = ...array of numbers...
        Dim hi as Integer = ...highest...
        Dim lo as Integer = ...lowest...

        ' we're going to assume that UBound(numbers) > 1
        Dim n as Integer = UBound(numbers) - 1
        Dim final as ??? = 1
        for i = 0 to n
                final = final * (hi - lo + 1) + (numbers(i) - lo)
        next i

To do this, you'll need a math package that can compute arbitrary
integers.

If you're willing to trade of some size for speed, you can do it at a
bit level.  For example, if the range of numbers is 1,000 to 10,000
(per my previous example), you can allocate 14 bits per number (10,000
- 1,000 is 9,000, which takes 14 bits) and do the shift and pack
thing.  Not quite as space efficient, but avoids the bignum math.

Or, you can pack on a byte level, taking 16 bits per number in this
example.  Again, even less space efficient but much easier
manipulation.

Life is even easier if you limit it to 1, 2, and 4 byte boundaries.

In any event, we need to know more about the time/space tradeoffs that
you'll have to make.

Craig

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to