STR$

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: STR$
Abbreviation: S, T, Shift+R
Type: Function
Token code: 196/$C4
Handling routine
in BASIC ROM:
46181–46214
$B465–B486
List of all BASIC keywords


Remark: This article describes the BASIC function STR$ in BASIC V2 at the Commodore 64.

Typ: String Function 
General Programming-Syntax: STR$(<numerical>)

STR$ is used to converting numerical values or variables into a string. When the number is positive or 0, the first char is a space. When it is a negative number, the first char is a minus (-).

If you call this on the wrong type of variable, like a string, the BASIC-error ?TYPE MISMATCH ERROR in line will be returned.

Like any numeric function, STR$ works if the expression evaluates to a value +/- 1e+38 or floating numbers with maximal 9 decimal places inside the range +/- 1e+28. If the resulting value is outside these bounds, the BASIC-error ?OVERFLOW ERROR IN line will be returned.

If the numerical argument is missing, the BASIC-error ?SYNTAX ERROR IN line is viewed.

Examples[edit | edit source]

PRINT STR$(1E11) (On screen: 1E+11)
PRINT STR$(0) (On screen: 0)
PRINT STR$(-1000) (On screen:-1000)
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