Hi,

I'm coding a function in order to test every calculations possible between x numbers.

I found over the net a pretty good algorithm which helped me a lot but it has its

limits... The prb with this code is that at some point it manage a bitwise comparison

(with AND operator) between 2 values, but when it reach very high numbers, it fails with

an overflow error due to the AND bitwise comparison which is limited to long values (32 bits)

in VB.

A simple example of the prb can be viewed just by typing following statement in the

debug/immediate window: ? 2^32 AND 2^32

So 1st question : how can i use double variables (64 bits) with the AND-bitwise-comparison ?

Or 2nd question : any better idea for achieving my goal ?

As far as i know, bitwise comparison is fast. However, with my current code, checking all possible

calculations for eg 20 amounts gives 1.048.555 possible calculations (((2 ^ (20)) - 1) - 20).

And computing all these calculations already takes a little more than 30 minutes on my PC.

I found an interesting thread on the subject in this site here :

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10042260.html
...but could not find out how to apply this for my prb :(

I also found a free dll (Binary Function Library 2.00) which seems very interesting, but as i'm not an

expert with bits, i couldn't sort this out myself either. The library can be found here :

http://www.windowsmarketplace.com/results.aspx?bCatID=63&av=14-190969
Thanks for the help,

Fiorah.

to use that library, put it in the same folder as your app (or the system32 dir)

you are interested in this declaration:

Declare Sub AndQ Lib "BinaryLib" (ByRef ArPattern As Any, ByRef Amount As Any, Optional ByVal ArPatternSize As Long = 8)

to use it with your example:

Private Sub Command1_Click()

Dim dblRet As Double

dblRet = 2 ^ 32

AndQ dblRet, 2 ^ 32

Debug.Print "the operation 2 ^ 32 AND 2 ^ 32 equals " & CStr(dblRet)

End Sub