Math.Not

Top  Previous  Next

 

Syntax

function Math.Not(Operand: integer): integer

function Math.Not(Operand: integer; CastResultAs: integer): integer

 

Alternative Names

ibec_Not

 

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:

_notUInt8
_notUInt16
_notUInt32
_notUInt64
_notInt8
_notInt16
_notInt32
_notInt64

Unsigned 8 bit value

Unsigned 16 bit value

Unsigned 32 bit value

Unsigned 64 bit value

Signed 8 bit value

Signed 16 bit value

Signed 32 bit value

Signed 64 bit value

 

Bitwise NOT is performed as follows for bit value p:

 

p

NOT

0

1

1

0

 

See Also

Math.And
Math.Or
Math.Xor

 

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