Monday, February 13, 2012

& character in Select statment

Hi Folks

If I wrote this in QA what does it mean?

Declare @.X INT
Set @.X = 2

Select (@.X & 8)

What & do in this select statment

Thank you

Hi,

& is a bitwise operator it perform a bit operation on the operands. bit value of 2 is

01

& for 8 it is

1000

and after bitwise calculation it comes out as 0

|||

Shallu is Right, but i would like to add somthing to it

The & performs the BITWISE AND operation

like in this case

Binary of 2 is 0010

Binary of 8 is 1000

now both of these performa AND operation bit by bit

0010

1000 (AND)

0000 (Result)

you can even performa any of the logical operation like

& => AND

| => OR

^ => EOR

~ => Negation

Regards,

Gurpreet S. Gill

|||Oh, Thank you both

I got it.

Thanks|||

thanks

Gurpreet S. Gill

No comments:

Post a Comment