ABS

From C64-Wiki
Jump to: navigation, search
BASIC keyword
Keyword: ABS
Abbreviation: A Shift+B
Type: Function
Token code: 182/$B6
Handling routine
in BASIC ROM:
48216–48218
$BC58–BC5A
List of all BASIC keywords


Remark: This article describes the BASIC-Command ABS in BASIC V2 at the Commodore 64.

Type: Numeric Function 
General Programming-Syntax: ABS(<numeric-expression>)

ABS evaluates to the absolute value (value without the sign) of the given numeric term.

If the term has no numeric value, the BASIC error ?TYPE MISMATCH ERROR [IN line] occurs. It can only be used for values from -1e+38 to 1e+38. If the argument is out of range the BASIC error?OVERFLOW ERROR [IN line] is shown.
When the numeric argument is absent, it displays a ?SYNTAX ERROR [IN line].

Examples[edit]

PRINT ABS(-10) (Screen: 10)
PRINT ABS(-10-11+5) (Screen: 16)
PRINT ABS("Text") (Screen: ?TYPE MISMATCH  ERROR)
PRINT ABS() (Screen: ?SYNTAX  ERROR)
BASIC V2.0 (second release) Commands

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