SGN
BASIC keyword | |
Keyword: | SGN |
Abbreviation: | S, Shift+G |
Type: | Function |
Token code: | 180/$B4 |
Handling routine in BASIC ROM: |
48185–48215 $BC39–BC57 |
List of all BASIC keywords |
Remark: This article describes the BASIC command SGN in BASIC V2 of the Commodore 64.
Typ: Numeric Function General Programming-Syntax: SGN(<Numeric>)
The function SGN gives autonomous of the algebraic sign the number (-1; 0; 1) of a numerical argument.
- values with negative prefix: -1
- zero: 0
- values with positive prefix: 1
When the term isn't a number, the BASIC error ?TYPE MISMATCH ERROR IN line occurs. It can be only used number with values from -1e+38 until 1e+38. Then this area is out of range the BASIC error?OVERFLOW ERROR IN line is viewing. When the numeric argument is absent, it appears a ?SYNTAX ERROR IN line.
Examples[edit | edit source]
PRINT SGN(-11) Result: -1 PRINT SGN(0.0) Result: 0 PRINT SGN(105) 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