I’ve been downloading code snippets and playing around with stuff.
I found a function that converts decimal numbers into a string that represents the binary value. The problem is that I have drawn a blank regarding one statement in the function:
DecToBin = CStr((DeciValue And 2 ^ i) / 2 ^ i) & DecToBin
The problem is (DeciValue And 2^i). As far as I can tell, it evaluates two numbers and then divides the result by 2^1 after that.
After plugging in some static values for testing, I still don’t get it.
Using just (DeciValue And i) in a For loop and outputting the value to the console:
DeciValue = 10
i=0-7
result: 0,0,2,2,0,0,2,2
DeciValue = 20
i=0-7
result: 0,0,0,0,4,4,4,4
DeciValue = 30
i=0-7
result: 0,0,2,2,4,4,6,6
DeciValue = 40
i=0-7
result: 0,0,0,0,0,0,0,0
DeciValue = 50
i=0-7
result: 0,0,2,2,0,0,2,2
I am most likely just having a stupid day and this is the most obvious thing in the world but I can’t seem to make heads or tails of it.
Thanks for any help.