Mega Code Archive

 
Categories / Delphi / Keywords
 

Not - boolean not or bitwise not of one arguments

1 Not Boolean expression 2 Not Integer expression Description The Not keyword is used in two different ways: 1. To perform a logical or boolean 'Not' of a logical value.If True, the value becomes False. If False, the value becomes True. 2. To perform a mathematical 'Not' of an integer in a bitwise fashion. The result is a bitwise 'Not' of the number - every bit value is reversed - 0 to 1 and 1 to 0. Notes If the boolean expression is calculated (as opposed to being a Boolean variable), then brackets are required to isolate it. Related commands And Boolean and or bitwise and of two arguments Boolean Allows just True and False values If Starts a conditional expression to determine what to do next Or Boolean or or bitwise or of two arguments Xor Boolean Xor or bitwise Xor of two arguments Example code : Illustrate both types of Not usage var num1, num2 : Word; begin num1 := $2C; // Binary value : 0000 0000 0010 1100 // Not'ed value : 1111 1111 1101 0011 = $FFD3 // And used to return a Boolean value if Not (num1 > 0) then ShowMessage('num1 <= 0') else ShowMessage('num1 > 0'); // And used to perform a mathematical NOT operation num2 := Not num1; // Display the result ShowMessage('Not $2C = $'+IntToHex(num2,2)); end; Show full unit code num1 > 0 Not $2C = $FFD3