48 of 318
ZBasic System Library 38 ZX Microcontroller Family CInt Type Function returning Integer Invocation CInt(arg) Parameter Method Type Description arg ByVal numeric, Boolean, String or Enum The value to convert to Integer. Discussion This function converts any numeric or enumeration value to an Integer value. See the table below for details of the conversion. Input Type Result Byte, Boolean High byte zero, low byte as supplied. Integer No effect, the value is as supplied. UnsignedInteger Value bits are the same as supplied, although interpreted as a signed value. Enum The resulting value is the Enum member value. Long The resulting value will be the low word of the supplied value. UnsignedLong The resulting value will be the low word of the supplied value. Single The supplied value is converted to 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 resulting integer is larger than will fit in 16-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 i as Integer i = CInt(2.5) ' result is 2 i = CInt(1.5) ' result is 2