Help Center
Help CenterFreeBASIC

Intfunction

Returns the floor of a number

Mathematical Functionsfunctiondocumented

Syntax

Declare Function Int ( ByVal number As Single ) As Single
Declare Function Int ( ByVal number As Double ) As Double
Declare Function Int ( ByVal number As Integer ) As Integer
Declare Function Int ( ByVal number As UInteger ) As UInteger

Parameters

NameDescription
numberthe floating-point number to round

Return value


Returns the floor of number, i.e. the largest integer that is less than or equal to it.

Description


Int returns the floor of number. For example, Int(4.9) will return 4.0, and Int(-1.3) will return -2.0. For integer types, the number is returned unchanged.

Note: To return the ceiling of number, i.e. the smallest integer that is greater than or equal to it, one can use -Int( -number ).

The Int unary Operator can be overloaded with user defined types.

Remarks

Usage


result = Int( number )

Dialect Differences


  • In the -lang qb dialect, this operator cannot be overloaded.

Differences from QB


  • None

See also


Example


Print Int(1.9)  '' will print  1

Print Int(-1.9) '' will print -2 


Reference

  • Documented in KeyPgInt.html