CUInt
 
将数字或字符串表达式转换为UIntegerUInteger<bits >

语法

Declare Function CUInt ( ByVal expression As datatype ) As UInteger
Declare Function CUInt<bits > ( ByVal expression As datatype ) As UInteger<bits >

Type typename
End Type

用法

result = CUInt( numeric expression )
result = CUInt( string expression )
result = CUInt( user defined type )

参数

bits
一个数字常量表达式,表示无符号整数所需的大小(以位为单位)。允许的值为8163264.
expression
要转换为UIntegerUintger<bits >值的数字,字符串或指针表达式
datatype
任何数字,字符串或指针数据类型
typename
用户定义的类型

返回值

这个 UIntegerUInteger<bits >包含转换的值。

说明

CUInt函数舍入小数部分并返回UInteger值,或者如果提供了bits 值,则给定大小的无符号整数类型。

该函数不检查溢出;例如,对于小于0或大于4967296的值,32位UInteger结果未定义。

该名称可以解释为“转换为无符号INTeger”。

如果参数是字符串表达式,则根据结果类型的大小,使用ValUIntValULng将其转换为数字。

例子

'使用CUINT函数转换数值

'创建一个UNSIGNED INTEGER变量
Dim numeric_value As UInteger

'转换数值
numeric_value = CUInt(300.23)

'打印结果= 300
Print numeric_value


方言差异

  • -lang qb 方言中不可用,除非使用别名__Cuint引用。

与QB差别

  • 新的FreeBASIC

参考