Article ID: 168344
Article Last Modified on 8/17/2005
<result> = <expression1> Imp <expression2>
Bit in Expression1 Bit in Expression2 Bit in Result
-------------------------------------------------------
1 1 1
1 0 0
0 1 1
0 0 1
For example, if you run the following macro, a message box displays the
value of -11:
Sub Imp_Example()
Dim a As Integer
Dim b As Integer
Dim result As Integer
a =10
b = 4
result = a Imp b
MsgBox result
End Sub
The value -11 is returned because the macro follows the rules in the table
and uses twos complement notation. Using twos complement notation, the
leftmost bit represents the sign bit. If this bit is one, the number is
negative; if this bit is zero, the number is positive. To convert a
negative number from binary back to decimal, complement all of the bits (1
becomes 0 and 0 becomes 1), convert that number to decimal, change the sign
of the decimal number, and then subtract 1.
10: 0000000000001010
4: 0000000000000100
10: 0000000000001010
4: 0000000000000100
--------------------------
result: 1111111111110101
To determine the decimal equivalent of result, use the twos complement
rules of conversion as follows:
Result: 1111111111110101
Complement each bit: 0000000000001010
Decimal equivalent of this binary number: 10
Opposite of this number: -10
Subtract 1 (decimal value of result): -11
imp
Additional query words: 97 XL97 XL
Keywords: kbhowto kbinfo kbprogramming KB168344