VB Code:
Dim decValue as Decimal = cDec(2^3+2^4+2^2+2^0) If DecValue = (decValue And 2^4) Then 'Fifth bit set Msgbox "Bit 5 is set" End if
This gives me a conversion error with Option Strict On
Do bitwise operators only work with Longs??
Printable View
VB Code:
Dim decValue as Decimal = cDec(2^3+2^4+2^2+2^0) If DecValue = (decValue And 2^4) Then 'Fifth bit set Msgbox "Bit 5 is set" End if
This gives me a conversion error with Option Strict On
Do bitwise operators only work with Longs??
Hi.
This is just a guess. I have not tried this, but I think That should propably be If DecValue = (decValue And cDec(2^4)) ThenQuote:
If DecValue = (decValue And 2^4) Then
What is it that you're trying to do? It's very unusual to be doing bitwise operations on decimals. If you think about the way that decimals are stored in memory you'll see what I mean. Using the correct casting you should be able to get rid of your Option Strict errors, but I'm still not sure that your code is going to make a lot of sense.