<< lowdisc_bitor Support Functions lowdisc_corrcoef >>

Low Discrepancy Toolbox >> Low Discrepancy Toolbox > Support Functions > lowdisc_bitxor

lowdisc_bitxor

Bitwise logical XOR operator.

Calling Sequence

y = bitxor ( x1 , x2 )

Parameters

x1 :

a n x 1 matrix of floating point integers

x2 :

a n x 1 matrix of floating point integers

y :

a n x 1 matrix of floating point integers

Description

Return the bitwise XOR of x1 and x2. This is the value that has 1 bits at positions where x1 and x2, but not both, have 1 bits. Does not work when one of the numbers is negative.

Note that this routine will work only up to 32 bits, or to the precision of your machine's double-precision float representation, whichever is smaller.

This routine is vectorized, i.e. it does take a column matrix n as input argument.

Examples

// Compute xor for several pairs of integers.
// In base-2, 86 = [1 0 1 0 1 1 0]'
lowdisc_bary ( 86 , 2 )
// In base-2, 19 = [1 0 0 1 1]'
lowdisc_bary ( 1 0 0 1 1 , 2 )
// The xor of [1 0 1 0 1 1 0]' and [1 0 0 1 1]' is [1 0 0 0 1 0 1]'
// The decimal value of [1 0 0 0 1 0 1]' is 69.
y = lowdisc_bitxor ( 86 , 19 )

// Compute xor for several pairs of integers.
mprintf("%5s %5s %15s %15s %15s %5s\n","x1","x2","x1 - Binary", "x2 - Binary", "xor - Binary" , "xor - Decimal");
mprintf("-------------------------------------\n");
x12 = [
86     19
90     31
32     48
4     22
41     36
55     71
77     77
37     57
100      8
99     76
];
for i = 1 : 10
y = lowdisc_bitxor ( x12(i,1) , x12(i,2) );
d1 = lowdisc_bary ( x12(i,1) , 2 );
d2 = lowdisc_bary ( x12(i,2) , 2 );
d3 = lowdisc_bary ( y , 2 );
mprintf("%5d %5d %15s %15s %15s %5d\n",x12(i,1),x12(i,2),strcat(string(d1)," "),strcat(string(d2)," "),strcat(string(d3)," "),y);
end

// This function is vectorized.
y = lowdisc_bitxor ( x12(:,1) , x12(:,2) )

Authors

<< lowdisc_bitor Support Functions lowdisc_corrcoef >>