Q(uick)BASIC Function: INT

Quick View

INT

A math function that returns the largest integer less than or equal to a numeric-expression

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • FIX(numeric-expression)
  • INT(numeric-expression)
Description/Parameter(s)
numeric-expression Any numeric expression.
Example
PRINT FIX(12.49), FIX(12.54) 'Output is: 12 12 PRINT INT(12.54), INT(-99.4) 'Output is: 12 -100

See also:

Syntax
  • INT(numeric-expression)
Description/Parameter(s)

The INT function removes the fractional part of its argument.

Example

This example compares output from INT, CINT, and FIX, the three functions that convert numeric data to integers.

CLS ' Clear screen PRINT " N","INT(N)","CINT(N)","FIX(N)" : PRINT FOR I% = 1 TO 6 READ N PRINT N, INT(N), CINT(N), FIX(N) NEXT DATA 99.3, 99.5, 99.7, -99.3, -99.5, -99.7

Sample Output:

N INT(N) CINT(N) FIX(N) 99.3 99 99 99 99.5 99 100 99 99.7 99 100 99 -99.3 -100 -99 -99 -99.5 -100 -100 -99 -99.7 -100 -100 -99
Syntax
  • INT(numeric-expression)
Description/Parameter(s)

Usage Notes

  • The INT function removes the fractional part of its argument.
Example

This example compares output from INT, CINT, and FIX, the three functions that convert numeric data to integers.

CLS 'Clear screen. PRINT " N", "INT(N)", "CINT(N)", "FIX(N)": PRINT FOR I% = 1 TO 6 READ N PRINT N, INT(N), CINT(N), FIX(N) NEXT DATA 99.3, 99.5, 99.7, -99.3, -99.5, -99.7

Sample Output:

N INT(N) CINT(N) FIX(N) 99.3 99 99 99 99.5 99 100 99 99.7 99 100 99 -99.3 -100 -99 -99 -99.5 -100 -100 -99 -99.7 -100 -100 -99