INT
Returns the integer value immediately lesser than or equal to the given number, also with a negative argument.
Implemented by: dartmouth3, ansimin, hptsb, decbasic, Altair, TI994, CBM, Atari, msatari, trs80, level2, trscolor, colormc, zx81, BBC, GWBASIC, MSX, bwbasic, bw32, ABasiC, QBasic, VBDOS, FreeBASIC, Gambas, minibasicmm, minibasicjs, EndBASIC
With variations: dartmouth1 ('always operates by chopping off the fractional part'), Applesoft (also used as a command to invoke INTEGER BASIC), spectrum
Also written as:
Usage
INT has been for long the math floor function of BASIC, to round fractional numbers down to the nearest lesser integer. This is not the same thing of a simple cut off of whatever comes after a decimal point, like FIX does. The difference is visible when the number to be converted is negative:
10 A = -12.35 20 PRINT INT(A) ' shows "-13" 30 PRINT FIX(A) ' shows "-12"
Variations
In Applesoft FP BASIC in the Apple II Plus and later computers, INT can also be used as a command, without arguments, for clearing the memory and starting INTEGER BASIC.
Examples
Comments
INT is one of the functions implemented since Dartmouth BASIC First Edition, but originally it worked more like the later FIX function for negative numbers. The manual for Second Edition/CARDBASIC states it clearly: "INT always operates by chopping off the fractional part". It became the "true floor" function in BASIC only from Dartmouth Third Edition onwards 1).