NEGATE: Difference between revisions
Jump to navigation
Jump to search
Add availability info |
Fix typo. |
||
Line 7: | Line 7: | ||
{{PageDescription}} | {{PageDescription}} | ||
* Unlike [[NOT]], which evaluates a value and returns the bitwise opposite, [[_NEGATE]] returns the logical opposite. Meaning that {{InlineCode}} | * Unlike [[NOT]], which evaluates a value and returns the bitwise opposite, [[_NEGATE]] returns the logical opposite. Meaning that {{InlineCode}}_NEGATE {{Parameter|non_zero_value}} = 0{{InlineCodeEnd}}. | ||
* Often called a negative logic operator, it returns the opposite of a value as true or false. | * Often called a negative logic operator, it returns the opposite of a value as true or false. | ||
Revision as of 16:10, 30 April 2024
_NEGATE is a boolean logical operator that will change a false statement to a true one and vice-versa.
Syntax
- result = _NEGATE value
Description
- Unlike NOT, which evaluates a value and returns the bitwise opposite, _NEGATE returns the logical opposite. Meaning that _NEGATE non_zero_value = 0.
- Often called a negative logic operator, it returns the opposite of a value as true or false.
Availability
-
none
-
v3.13.0
-
yes
-
yes
-
yes
Examples
Example: NOT versus _NEGATE
DECLARE LIBRARY FUNCTION isdigit& (BYVAL n AS LONG) END DECLARE IF NOT isdigit(ASC("1")) THEN PRINT "NOT: 1 is not a digit." ELSE PRINT "NOT: 1 is a digit." END IF IF _NEGATE isdigit(ASC("1")) THEN PRINT "_NEGATE: 1 is not a digit." ELSE PRINT "_NEGATE: 1 is a digit." END IF END |
NOT: 1 is not a digit. _NEGATE: 1 is a digit. |
- Explanation: NOT is a bitwise operator that inverts all the bits in an integer, whereas _NEGATE is a logical operator that flips the truth value of a boolean expression.
See also