Math.Not |
Top Previous Next |
Syntax function Math.Not(Operand: integer): integer function Math.Not(Operand: integer; CastResultAs: integer): integer
Alternative Names
Description Performs a bitwise logical Not operation.
The Operand holds a value and the Return Value is a bitwise logical NOT operation for each bit in the input value, defaulting to a 32 bit signed integer value.
Optionally a value for CastResultAs determines how the return value is typed, it can be one of the following predefined constants:
Bitwise NOT is performed as follows for bit value p:
See Also
Example execute UDSBlock as begin Operand = 65538; /* defaults to signed 32 bit, 0000 0000 0000 0001 0000 0000 0000 0010 in binary */ Res = Math.Not(Operand); /* Result 1111 1111 1111 1110 1111 1111 1111 1101 in binary */ GUI.ShowMessage('Result 1111 1111 1111 1110 1111 1111 1111 1101 (bin) = -65539 (dec): ' || Res);
Res = Math.Not(Operand, __notUInt32); /* Result 1111 1111 1111 1110 1111 1111 1111 1101 in binary */ GUI.ShowMessage('Result 1111 1111 1111 1110 1111 1111 1111 1101 (bin) = 4294901757 (dec): ' || Res); /* results in 4294901757 as signed 32 bit */
Res = Math.Not(Operand, __notUInt8); /* Result 1111 1101 in binary */ GUI.ShowMessage('Result 1111 1101 (bin) = 253 (dec): ' || Res); /* results in 253 as unsigned 8 bit */
Res = Math.Not(Operand, __notInt8); /* Result 1111 1101 in binary */ GUI.ShowMessage('Result 1111 1101 (bin) = -3 (dec): ' || Res); /* results in -3 as signed 8 bit */ end |