INT

From C64-Wiki
Jump to: navigation, search
BASIC keyword
Keyword: INT
Abbreviation:
Type: Function
Token code: 181/$B5
Handling routine
in BASIC ROM:
48332–48360
$BCCC–BCE8
List of all BASIC keywords


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

Typ: Integer Function 
General Programming-Syntax: INT(<Numeric>)

INT is used to round numbers, whereas rounding is different from its common mathematical definition. By positive numbers the fractional part will be cut, while by neagtive numbers the next lower integer value is returned.

By adding 0.5 to the argument the conventional mathemathical rounding can be implemented.

When the argument does not evaluate to a number, the BASIC error ?TYPE MISMATCH ERROR IN line occurs. It can be only used with values from -1e+38 to 1e+38. If the value is out of range, you get the BASIC error?OVERFLOW ERROR IN line. When the numeric argument is absent, it displays a ?SYNTAX ERROR IN line.

Examples[edit]

PRINT INT(1.53)   Screen: 1
PRINT INT(-9.47)  Screen: -10
       for correct rounding add 0.5
PRINT INT((1.53)+0.5)   Screen: 2
PRINT INT((-9.47)+0.5)  Screen: -9
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