Skip to main content

INT

Returns the integer component of an expression.

Synopsis

INT(string)

Arguments

string An expression that resolves to a number or numeric string.

Description

The INT function returns the integer portion of a numeric or numeric string. It returns both positive and negative integers. Fractional numbers are truncated (not rounded) to an integer. A zero, an empty string (""), or a non-numeric string all return the integer 0.

For numbers and numeric strings, prior to determining the integer, MVBasic performs all arithmetic operations and converts numbers to canonical form, with leading and trailing zeroes, a trailing decimal point, and all signs removed except a single minus sign.

Examples

The following examples all use the INT function to return the integer 321:

PRINT INT(321.37);        ! Returns 321
PRINT INT(321.99);        ! Returns 321
PRINT INT("--00321.6");   ! Returns 321
PRINT INT("321blastoff"); ! Returns 321

See Also

FeedbackOpens in a new tab