Thanks.
Manoel Campos da Silva Filho a écrit :
> Hi people. I'm newbie in MatLab and SciLab and I like to know if
> exists a exclusive or logical operator in SciLab.
from a mathematical point of view :
"xor" = "booleans are not equal" = "<>"
we can easily verify this :
-->%t<>%f
ans =
T
-->%t<>%t
ans =
F
-->%f<>%f
ans =
F
-->%f<>%t
ans =
T
Philippe
You should go on the web site of Wikipedia, especially on Wikibooks or
http://fr.wikiwix.com/index.php?lang=en&disp=book or the Scilab own
site.
Wikibooks is fine because, every operator and function are explained.
Good luck!
Sam
Hi,
This is a small implementation I found somewhere on the web. I
converted the code to Scilab and left all remarks as they are.
Good luck with your learning,
Moti
function y = bitxor(x1, x2)
//BITXOR Bitwise logical XOR operator.
//
// y = bitxor(x1,x2)
// 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.
//
// See also bitand, bitor, any, all, |, &, xor.
// Dave Mellinger
// 27 May 1995
// using a global is slightly faster than recomputing bit_vals every
time (Sun),
// but unfortunately in MATLAB 5.0 you can't tell if globals already
exist.
bit_vals = 2 .^ (0:31);
x1 = pmodulo(floor(x1 ./ bit_vals), 2);
x2 = pmodulo(floor(x2 ./ bit_vals), 2);
y = sum(bit_vals .* pmodulo(x1 + x2, 2));
endfunction