mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
1.0 KiB
1.0 KiB
Function xor
Logical xor. Test whether one and only one value is defined with a nonzero/nonempty value.
For matrices, the function is evaluated element wise.
Syntax
math.xor(x, y)
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
number | BigNumber | Complex | Unit | Array | Matrix | First value to check |
y |
number | BigNumber | Complex | Unit | Array | Matrix | Second value to check |
Returns
| Type | Description |
|---|---|
| boolean | Array | Matrix | Returns true when one and only one input is defined with a nonzero/nonempty value. |
Examples
math.xor(2, 4); // returns false
a = [2, 0, 0];
b = [2, 7, 0];
c = 0;
math.xor(a, b); // returns [false, true, false]
math.xor(a, c); // returns [true, false, false]