Download or view bitwiseXOR.frink in plain text format
// Sample program to perform a bitwise XOR on two numbers.
// NOTE: This is no longer necessary as Frink has a built-in
// bitXor[a,b] function.
bitwiseXOR[a,b] :=
{
c = 0
len = max[bitLength[a], bitLength[b]]
for digit = len-1 to 0 step -1
{
abit = getBit[a, digit] == 0 ? false : true
bbit = getBit[b, digit] == 0 ? false : true
c = c*2 + (abit XOR bbit ? 1 : 0)
}
return c
}
Download or view bitwiseXOR.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 19764 days, 3 hours, 43 minutes ago.