Retreiving the value of each bit of a Long value
Posted on 2005-05-15
I am trying to interogate each bit of a Long value (32 bits). I use the following code to do so.
dim longValue as long
dim j as Integer
dim k as long
For j = 0 To 31
k = longValue And (2 ^ j))
k = IIf(k > 0, "1", "0")
rStr = rStr & k
When i get to 2^31 i get an overflow because this value is greater than that of a long.
Can anyone think of a beter way of finding the bit value of each bit in a long word. I am thinking of doing bitwise shifts to shift right the 32nd bit to avoid this.