Int() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns an integer value obtained by removing the fractional part of a decimal value. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Int( num_expr )

num_expr is a numeric expression.

Return Value

Integer

Description

The Int() function returns the nearest integer value that is less than or equal to the specified num_expr expression. The Fix() function is similar to, but not identical to, the Int() function. The two functions differ in the way that they treat negative fractional values. When passed a negative fractional number, Fix() function will return the nearest integer value greater than or equal to the original value; so, the function call Fix(-2.3) will return a value of -2. But when the Int() function is passed a negative fractional number, it returns the nearest integer value that is less than or equal to the original value. So, the function call Int(-2.3) returns a value of -3.

Example

Dim whole As Integer
whole = Int(5.999)
' whole now has the value 5

whole = Int(-7.2) 
' whole now has the value -8 

See Also:

Fix() function, Round() function