NOT
BASIC keyword | |
Keyword: | NOT |
Abbreviation: | N, Shift+O |
Type: | Operator |
Token code: | 168/$A8 |
Handling routine in BASIC ROM: |
44756?–44770 $AED4–AEE2 |
List of all BASIC keywords |
Remark: This article describes the BASIC-Command NOT in BASIC V2 at the Commodore 64.
Type: Boolean/bitwise operator General Programming-Syntax: NOT <Boolean/integer term>
NOT reverse the boolean "true" into "false". This can be used in IF/THEN construct.
Use of non-numerical terms in conjunction with NOT causes a ?TYPE MISMATCH ERROR IN line. In the case of bitwise NOT operations the range of −32768 thru 32767, or −$8000 thru $7FFF in hexadecimal — terms outside of this range will raise an ?ILLEGAL QUANTITY ERROR IN line. If either of the terms are absent, a ?SYNTAX ERROR IN line will occur.
In the case of bitwise NOT operations, both terms are evaluated as 16-bit signed integers, and thus cannot exceed the range of −32768 thru 32767, or −$8000 thru $7FFF in hexadecimal — terms outside of this range will raise an ?ILLEGAL QUANTITY ERROR IN line. If either of the terms are absent, a ?SYNTAX ERROR IN line will occur.
Note that in BASIC on the C-64, the boolean value "true" is represented by the integer −1, which is all bits set in the 16-bit signed format, while the value "false" is represented by the value 0, or all bits clear.
Examples[edit]
IF NOT A=1 AND NOT C=0 THEN PRINT "HALLO" (HALLO is printed, when the variable A is unequally 1 and the varibale C is unequally 0.) IF NOT A$<>"Saturday" THEN PRINT A$ (A$ is printed, when the contain of the variable is equal Saturday)
Boolean algebra
PRINT NOT(2) (Result: -3) PRINT NOT(1) (Result: -2) PRINT NOT(0) (Result: -1) PRINT NOT(-1) (Result: 0) PRINT NOT(-2) (Result: 1)
ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT