# CLNG

CLNG(expression)

Returns the expression converted to a long data type (Long).

 expression The expression to evaluate and convert to a long.

 REMARKS
 * The Long data type is a Value data type.* The "expression" can be any number between -2.1 E+9 and +2.1 E+9.* If "expression" includes any fractions or decimals these are rounded.* If "expression" is outside the range of the data type being converted to, an error occurs.* Any fractional parts greater than 0.5 are rounded up.* Any fractional parts less than 0.5 are rounded down.* Any fractional parts equal to 0.5 are rounded to the nearest even number.* This type of rounding is called banker's rounding and its purpose is to compensate for a bias that could accumulate when adding a lot of 0.5 fractions.* You can use the CDBL function to return an expression converted to a Double data type.* You can use the CINT function to return an expression converted to an Integer data type.* You can use the CSNG function to return an expression converted to a Single data type.* You can use the CLNGLNG function to return an expression converted to a LongLong (64 bit platform) data type.* You can use the CLNGPTR function to return a LongPtr data type.* For a full list of conversion functions refer to the Explicit Conversion page.* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print CLng(0.5)        '= 0
Debug.Print CLng(0.6) '= 1
Debug.Print CLng(1.4) '= 1
Debug.Print CLng(1.5) '= 2 rounded up to 2
Debug.Print CLng(2.5) '= 2 rounded down to 2
Debug.Print CLng(2.6) '= 3
Debug.Print CLng(2.9) '= 3
Debug.Print CLng(3.4) '= 3
Debug.Print CLng(3.5) '= 4
Debug.Print CLng("1234567") '= 1234567

Dim lNumber As Long
Dim dbValue As Double
dbValue = 30.75
lNumber = CLng(dbValue)
Debug.Print lNumber
Debug.Print TypeName(lNumber) '"Long"