This can be reduced to a one-liner. The following version works on machines that use twos-complement arithmetic (PCs). Instead of a single bit, you can supply a mask. Also, the arguments are interchangeable.
Function XOR($BinaryVal, $Mask)
$XOR = ($BinaryVal | $Mask) & (-1 - ($BinaryVal & $Mask))
EndFunction
_________________________
Paul Lemaire
Ace Consulting
Reality is stranger than fiction.