# Data type conversion

LotusScript® implicitly converts data from one type to another in the following situations.

## Numeric operations

When numeric values with different data types are used in a numeric operation, LotusScript® converts the values to the same data type for evaluation.

In general, LotusScript® converts to the higher data type, based on this list (lowest to highest): Byte, Integer, Long, Single, Double, Currency. For example, in an operation with one Integer operand and one Double operand, LotusScript® converts the Integer value to a Double before evaluating the expression.

Specific rules for conversion in operations are detailed in the documentation of the individual operators.

## Argument passing

When a numeric argument is passed by value to a procedure, LotusScript® tries to convert the value if it is not the expected data type. If the value is too large, the operation generates an error.

When a numeric argument is passed by reference to a procedure, the data type of the reference must match that of the declared argument, unless the declared argument is Variant.

## Variant variables

When a value is contained in a Variant variable, LotusScript® tries to convert the value to a number or a string, depending on the context.

Data type conversion treats a value of one data type as though it were a value of a different data type or performs an operation on a value of one data type to produce a value of another data type. Some form of data type conversion is involved when you add two numbers of different data types together, print the hexadecimal representation of a decimal number as a string, or calculate a date/time value (by treating that value as though it were a number).You can perform a data type conversion explicitly with the functions that LotusScript® provides, you can choose between the two methods of conversion, or LotusScript® can perform the conversion automatically. For example:

``````Dim aString As String
Dim aFloat As Currency
Dim aVariantV As Variant

aString\$ = "123.45"

' Explicitly convert a string to a Currency value.
' That is, assign the return value of the conversion
' function CCur, which takes a String argument, to a variable
' of type Currency.
aFloat@ = CCur(aString\$)
Print aFloat@
' Output: 123.45
' Automatically convert a Double value
' to a Currency value by assignment. You
' could explicitly convert the value of
' aDouble# to a Currency value before
' assigning it to aFloat@. You might do
' this for the purposes of documentation.