Skip to content

CUINT


将数值或字符串表达式转换为 UintegerUinteger<bits>

语法

vb
declare function Cuint ( byval expression as datatype ) as uinteger
declare function Cuint`<bits>` ( byval expression as datatype ) as uinteger`<bits>`

Type typename

declare operator cast ( ) as uinteger
declare operator cast ( ) as uinteger`<bits>`

End Type

用法

vb
result = Cuint( numeric expression )
result = Cuint( string expression )
result = Cuint( user defined type )

参数

bits

表示所需无符号整数位数的数值常量表达式。允许的值为 8163264

expression

要转换为 UintegerUinteger<bits> 值的数值、字符串或指针表达式

datatype

任何数值、字符串或指针数据类型

typename

用户自定义类型

返回值

包含转换后值的 UintegerUinteger<bits>

说明

Cuint 函数舍去小数部分并返回 Uinteger 值;若提供了 bits 值,则返回给定大小的无符号整数类型。

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

函数名可以理解为"转换为无符号整数"(Convert to Unsigned INTeger)。

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

示例

start GeSHi

vb
' Using the CUINT function to convert a numeric value

'Create an UNSIGNED INTEGER variable
Dim numeric_value As UInteger

'Convert a numeric value
numeric_value = CUInt(300.23)

'Print the result = 300
Print numeric_value

end GeSHi

方言差异

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

与 QB 的差异

  • FreeBASIC 新增特性

另请参阅

  • Cbyte
  • Cubyte
  • Cshort
  • Cushort
  • Cint
  • Clng
  • Culng
  • Clngint
  • Culngint
  • Csng
  • Cdbl
  • Uinteger

返回 目录

基于 FreeBASIC 官方文档翻译 如有侵权请联系我们删除
FreeBASIC 是开源项目,与微软公司无隶属关系