Results 1 to 6 of 6

20081213, 21:05 #1
 Join Date
 Jan 2001
 Location
 Alzano Lombardo, Italy
 Posts
 1,483
 Thanks
 0
 Thanked 0 Times in 0 Posts
A Bit of Set Theory Doesn't Hurt... (2003)
In the VBA Editor's Immediate window, if I type
? 3 AND 4
I get 0
but if I type
? 3 AND 4
I get 4
What's the rationale behind it?

20081213, 22:00 #2
 Join Date
 Dec 2001
 Location
 Melbourne, Australia
 Posts
 4,594
 Thanks
 0
 Thanked 27 Times in 27 Posts
Re: A Bit of Set Theory Doesn't Hurt... (2003)
Look at the values in hex:
4 is FB which is 1111 1011 in binary
3 is FC which is 1111 1100 in binary
So if you and them you get 1111 1000 whic is 4

20081213, 23:01 #3
 Join Date
 Jan 2001
 Location
 Alzano Lombardo, Italy
 Posts
 1,483
 Thanks
 0
 Thanked 0 Times in 0 Posts
Re: A Bit of Set Theory Doesn't Hurt... (2003)
Thanks Pat, if, in the Immediate window, I type
?Hex(3) I get
FFFD
?Hex(4)
I get
FFFC

20081214, 12:06 #4
 Join Date
 Mar 2002
 Posts
 84,353
 Thanks
 0
 Thanked 29 Times in 29 Posts
Re: A Bit of Set Theory Doesn't Hurt... (2003)
Decimal 3 = hexadecimal FFFD = binary 1111 1111 1111 1101
Decimal 4 = hexadecimal FFFC = binary 1111 1111 1111 1100
The rules for binary And are:
1 And 1 = 1
1 And 0 = 0
0 And 1 = 0
0 And 0 = 0
So decimal 3 And 4 = hexadecimal FFFD And FFFC = binary 1111 1111 1111 1101 And 1111 1111 1111 1100 = 1111 1111 1111 1100 = hexadecimal FFFC = decimal 4

20081214, 19:38 #5
 Join Date
 Jan 2001
 Location
 Alzano Lombardo, Italy
 Posts
 1,483
 Thanks
 0
 Thanked 0 Times in 0 Posts
Re: A Bit of Set Theory Doesn't Hurt... (2003)
Thank you Hans, what part of the hexadecimal notation accounts for the negative sign?

20081214, 19:57 #6
 Join Date
 Mar 2002
 Posts
 84,353
 Thanks
 0
 Thanked 29 Times in 29 Posts
Re: A Bit of Set Theory Doesn't Hurt... (2003)
The first bit in the number indicates negativity, i.e. if the hexadecimal notation starts with 8, 9, A, B, C, D, E or F, the number is negative.