Page 74 of 346 Start Back Next End ZBasic System Library 62 ZBasic Microcontrollers CLng Type Function returning Long Invocation CLng(arg) Parameter Method Type Description arg ByVal numeric, Boolean, String or Enum The value to convert to Long. Discussion This function converts any numeric or enumeration value to a Long value. See the table below for details of the conversion. Input Type Result Byte, Boolean High 3 bytes zero, low byte as supplied. Integer High word will be all ones if the supplied value is negative, zero otherwise. Low word as supplied. UnsignedInteger High word zero, low word as supplied. Enum The resulting value is the Enum member value. Long No effect, the value is as supplied. UnsignedLong Value bits are the same as supplied, although interpreted as a signed value. Single The supplied value is converted to a signed 32-bit integer, rounded to the nearest integer. If the fractional part is exactly 0.5, the resulting integer will be even. This is known as “statistical rounding”. If the magnitude of the supplied value is too large to be represented in 32 bits, the result is undefined. String The result is the numeric value of the characters in the string, ignoring leading space and tab characters. The value string may begin with a plus or minus sign and an optional radix indicator (&H for hexadecimal, &O for octal, &B or &X for binary, all case insensitive). The conversion is terminated upon reaching the end of the string or encountering the first character that is not valid for the indicated radix. Example Dim l as Long l = CLng(2.5) ' result is 2 l = CLng(1.5) ' result is 2