Velocity Reviews > Logical operation

# Logical operation

c.h1523@hotmail.com
Guest
Posts: n/a

 05-06-2009
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 ?

Lawrence Garvin [MVP]
Guest
Posts: n/a

 05-06-2009
"(E-Mail Removed)" <(E-Mail Removed)@discussions.microsoft.com> wrote
in message news:(E-Mail Removed)...
> 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/pro...awrence.Garvin