m (→See also: add rots) |
(superseded by ^^) |
||
Line 1: | Line 1: | ||
+ | {{Superseded}} |
||
{{ApiReference |
{{ApiReference |
||
|name=bxor |
|name=bxor |
||
Line 5: | Line 6: | ||
|second||The second number. |
|second||The second number. |
||
}} |
}} |
||
+ | |||
+ | == Superseded by ^^ operator == |
||
+ | |||
+ | The <code>^^</code> operator added in 0.2.0 performs the same function as <code>bxor()</code> and is now the recommended way to do bitwise xor, as it uses fewer tokens, costs fewer cycles at runtime, and runs on the real host CPU much more efficiently. Simply replace <code>bxor(a,b)</code> with <code>a^^b</code>. |
||
== Examples == |
== Examples == |
||
Line 13: | Line 18: | ||
-- 0xc = 1100 binary |
-- 0xc = 1100 binary |
||
print(bxor(0x5, 0x9)) -- 12 (0xc) |
print(bxor(0x5, 0x9)) -- 12 (0xc) |
||
+ | |||
+ | print(0x5 ^^ 0x9) -- preferred method |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Revision as of 04:50, 6 May 2020
Superseded / Deprecated
The feature described in this article has been superseded by a newer feature. This feature still works in PICO-8, but the new feature should be used instead. See the article's "Superseded by..." section for specific details.
bxor( first, second )
- Calculates the bitwise exclusive or of two numbers.
- first
-
- The first number.
- second
-
- The second number.
Superseded by ^^ operator
The ^^
operator added in 0.2.0 performs the same function as bxor()
and is now the recommended way to do bitwise xor, as it uses fewer tokens, costs fewer cycles at runtime, and runs on the real host CPU much more efficiently. Simply replace bxor(a,b)
with a^^b
.
Examples
-- 0x5 = 0101 binary
-- xor 0x9 = 1001 binary
-- -------
-- 0xc = 1100 binary
print(bxor(0x5, 0x9)) -- 12 (0xc)
print(0x5 ^^ 0x9) -- preferred method