INT

INT(number)

Returns the integer portion of a number (data type).


numberThe number (data type)

REMARKS
* The fractional/decimal part of the number is removed.
* This function is identical to the FIX function for positive numbers.
* This function truncates without rounding.
* The value returned has the same data type as the value passed in.
* If "number" is Null, Null is returned.
* If "number" < 0, then the first negative integer less than or equal to "number" is returned.
* You can use the FIX function to return the integer portion of a number.
* You can use the ROUND function to return a number rounded to a given number of decimal places.
* The equivalent .NET function is Microsoft.VisualBasic.Conversion.Int
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print Int(-8.9)   '= -9  
Debug.Print Int(-8.4) '= -9
Debug.Print Int(-8.1) '= -9
Debug.Print Int(-7.9) '= -8
Debug.Print Int(-1.9) '= -2
Debug.Print Int(-1.1) '= -2
Debug.Print Int(-0.1) '= -1
Debug.Print Int(0.2) '= 0
Debug.Print Int(0.5) '= 0
Debug.Print Int(0.6) '= 0
Debug.Print Int(0.9) '= 0
Debug.Print Int(1.1) '= 1
Debug.Print Int(1.5) '= 1
Debug.Print Int(12.01) '= 12
Debug.Print Int(12.34) '= 12
Debug.Print Int(12.99) '= 12

Dim iInteger As Integer
iInteger = 20
Debug.Print TypeName(Int(iInteger)) '= Integer

Dim lLong As Long
lLong = 20.5
Debug.Print TypeName(Int(lLong)) '= Long

Dim dbDouble As Double
dbDouble = 20.5
Debug.Print TypeName(Int(dbDouble)) '= Double

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top