78 of 323
ZBasic System Library 68 ZX Microcontroller Family CUInt Type Function returning UnsignedInteger Invocation CUInt(arg) Parameter Method Type Description arg ByVal numeric, Boolean, String or Enum The value to convert to UnsignedInteger. Discussion This function converts any numeric or enumeration value to an UnsignedInteger value. See the table below for details of the conversion. Input Type Result Byte, Boolean High byte zero, low byte as supplied. Integer Value bits are the same as supplied, although interpreted as an unsigned value. UnsignedInteger No effect, the value is as supplied. Enum Resulting value is the Enum member value. Long Resulting value is the low word of the supplied value. UnsignedLong Resulting value is the low word of the supplied 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 resulting signed integer is negative or larger than 65535, the result is undefined. Otherwise, the result is the value of the integer. 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 u as UnsignedInteger u = CUInt(2.5) ' result is 2 u = CUInt(1.5) ' result is 2 Compatibility The ability to convert from Single is not supported in BasicX compatibility mode.