Share via


BITXOR( ) Function

Perform a bitwise exclusive OR operation on two or more values of Numeric, Varbinary, or Blob type and returns the result. There is a numeric and a binary version of the syntax.

BITXOR(nNumericExpression1, nNumericExpression2 ..., nNumericExpression26)

BITXOR(BinaryExpression1, BinaryExpression2 ..., BinaryExpression26)

Parameters

  • nNumericExpression1, nNumericExpression2, ... , nNumericExpression26
    Specifies Numeric values to perform the bitwise exclusive OR operation.

  • BinaryExpression1, BinaryExpression2, ... , BinaryExpression26
    Specifies Varbinary or Blob values to perform the bitwise exclusive OR operation.

    Note

    You can specify a maximum of 26 values. The specified values must have the same type. If the specified expressions are not integers, they are converted to integers before performing the operation. Not applicable for Varbinary input parameters.

Return Value

Numeric or Varbinary. BITXOR( ) returns the result of the bitwise exclusive OR operation performed on the specified expressions.

Note

For Varbinary or Blob values, the return value is calculated as if all values are padded with 0h00 on the right of the value up to the length of the longest value. The appropriate operation is then performed between those values.

Remarks

BITXOR( ) compares each bit in eExpressionN to the corresponding bit in eExpressionN+1. If the bits in eExpressionN and eExpressionN+1 are the same, the corresponding result bit is set to 0; otherwise, the corresponding result bit is set to 1.

The following table shows the result of an exclusive OR operation on corresponding eExpressionN and eExpressionN+1 bits:

eExpressionN bit

eExpressionN+1 bit

Result bit

0

0

0

0

1

1

1

0

1

1

1

0

Example

The following example stores a value of 5, which has a binary value of 0101, to variable Var1 and a value of 6, which has a binary value of 0110, to variable Var2. BITXOR( ) returns a value of 3, which has a binary value of 0011.

Var1 = 5  && 0101 binary value
Var2 = 6  && 0110 binary value
? BITXOR(Var1,Var2) && returns 3 (0011 binary value)

See Also

Reference

BITAND( ) Function

BITCLEAR( ) Function

BITLSHIFT( ) Function

BITNOT( ) Function

BITOR( ) Function

BITRSHIFT( ) Function

BITSET( ) Function

BITTEST( ) Function

Other Resources

Functions

Language Reference (Visual FoxPro)