# Logical operation

Discussion in 'Microsoft Certification' started by c.h1523@hotmail.com, May 6, 2009.

1. ### Guest

This is a test for the high school :

the logical operation as this ("a">"A" xor 1), and get the result is -2,
what is the negative value meaning ?
, May 6, 2009

2. ### Lawrence Garvin [MVP]Guest

"" <@discussions.microsoft.com> wrote
in message news:...
> This is a test for the high school :
>
> the logical operation as this ("a">"A" xor 1), and get the result is -2,
> what is the negative value meaning ?

You cannot draw inferences from the negative or positive nature of the
value.

Most systems define True/False as non-zero and zero.

But, to explain what has actually happened....

First you performed a logical comparison "a" > "A" which is True, and
returned some non-zero result.

And then you performed an XOR operation with the value '1'
(<some_nonzero_value> XOR 0x00000001),
and it looks like the value returned is 0xFFFFFFFE, of which the last eight
bits are 0x111111110,
and that's where the -2 is coming from.

From that, we can "reverse engineer" the logic, and consider this
possibility:
If the nonzero value returned was -1 (0xFFFFFFFF) then the result of
0xFFFFFFFF XOR 0x00000001
is that the last bit is set to 0 (XOR fails), and all other bits are set to
1 -- and the result is -2.

--
Lawrence Garvin, M.S., MCITP:EA, MCDBA
Principal/CTO, Onsite Technology Solutions, Houston, Texas
Microsoft MVP - Software Distribution (2005-2009)

MS WSUS Website: http://www.microsoft.com/wsus
My Websites: http://www.onsitechsolutions.com;
http://wsusinfo.onsitechsolutions.com
My MVP Profile: http://mvp.support.microsoft.com/profile/Lawrence.Garvin
Lawrence Garvin [MVP], May 6, 2009