Bitwise Eqv / AND

Hi everyone,

Perhaps someone could clarify the difference between a bitwise EQV and AND operation. Reading through the help file they sound as if they should be the same, but they are obviously not and I don’t understand why.

Here’s my test code which I was using to mess around with this as I’ve never really used it before and was interested in learning what I’d understood in principle!

Const BOLD = 1 ’ 0001

Const ITALIC = 2				' 0010

Const UNDERLINE = 4				' 0100



Dim style As Integer

style = BOLD+ITALIC				' 0011



' These AND's work as I would expect

MsgBox (style And BOLD)			' returns 1

MsgBox (style And ITALIC)		' returns 2

MsgBox (style And UNDERLINE)	' returns 0



' These EQV's I don't understand

MsgBox (style Eqv BOLD)			' returns -3

MsgBox (style Eqv ITALIC)		' returns -2

MsgBox (style Eqv UNDERLINE)	' returns -8

Cheers,

Craig.

Subject: Typically found the answer right after…

Gah, typical… found the answer now right after posting.

With AND

0 AND 0 = 0

With EQV

0 EQV 0 = 1

Subject: AND is not EQV

[Edit] Oops, didn’t see the answer when replied [/Edit]Hi,

There is a huge difference between both operands :

0 AND 0 = 0

O EQV 0 = 1

In other words when comparing two false statements AND will return false, EQV will return true.

The others comparison give the same result.

And 0 0 0

0 	1 	0 

1 	0 	0 

1 	1 	1 

Eqv 0 0 1

0 	1 	0 

1 	0 	0 

1 	1 	1

Subject: By the time I posted…

…I’d had so many zero’s and one’s in front of my eyes, I missed the difference in the help files!

C.