Topic: DMD0348 Math Bit-wise XOR Operator |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
The Math Bit-wise XOR operator ( ^ ) compares each bit of its first operand to the corresponding bit of its second operand. If one bit is 0 and the other bit is 1, the corresponding bit of the result is set to 1. If both bits are 1 or both bits are 0 the corresponding bit of the result is set to 0.
Note: bit-wise XOR operations are typically only used for unsigned hexadecimal values and unsigned integer memory locations. Using the :U cast operator on signed 16-bit values will cause them to be processed as unsigned 16-bit values. There is no unsigned cast operation for 32-bit signed values.
The operands can be any mix of signed integers, unsigned integers, real (floating point) numbers or discrete values. They can be any numeric or discrete memory location, or any numeric or discrete structure member.
All discrete values and all 16-bit integer values are promoted to 32-bit 2's complement signed integer values. If a Real value is included in the equation then all of the values will be promoted to Real values and all calculations will be performed using Real numbers.
Traditional math precedence rules are used to solve the math expression. The use of parentheses to remove any ambiguity in the processing order is encouraged.
Refer to the examples below:
As stated earlier, bit-wise operations are intended for use on Unsigned integer values, NOT Signed integer values or Real values. The following examples are here only to provide understanding in how these values will be processed by the math stack, the result that is generated is typically not useful.
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
See Also:
Bit-wise XOR
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
Related Topics:
|
||||||||||||||||||||||||
|