xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

NumXOR()

Performs a bitwise XOR operation with two numeric 32-bit integer values.

Syntax

NumXOR( <nInteger1>|<cHex1>, ;
        <nInteger2>|<cHex2>  ) --> nInteger

Arguments

<nInteger>
A numeric 32-bit integer value can be specified for both parameters.
<cHex>
Alternatively, the two integers can be specified as hex-encoded character strings (see NumToHex()).

Return

The function returns the result of an exclusive OR operation with the bits of both parameters as a numeric value. The bits are set in the result where the bits of both parameters are different.

Info

See also:IsBit(), NumAND(), NumNOT(), NumOR(), NumXorX(), SetBit()
Category: CT:NumBits , Bitwise functions , Numbers and Bits
Source:ct\bit1.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays the results of exclusive OR operations and
// their binary representation.

   PROCEDURE Main
      LOCAL nValue1 := 6
      LOCAL nValue2 := 23
      LOCAL nResult

      ? NtoC( nValue1, 2, 8, "0" ) // result: 00000110
      ? NtoC( nValue2, 2, 8, "0" ) // result: 00010111


      nResult := NumXOR( nValue1, nValue2 )
      ? nResult                    // result: 17
      ? NtoC( nResult, 2, 8, "0" ) // result: 00010001

      nResult := NumXOR( nValue1, nResult )
      ? nResult                    // result: 23
      ? NtoC( nResult, 2, 8, "0" ) // result: 00010111

      ? nResult == nValue2         // result: .T.
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe