Skip to content

WHEX


返回数字的十六进制 wstring(Unicode)表示

语法

vb
declare function Whex ( byval number as ubyte ) as wstring
declare function Whex ( byval number as ushort ) as wstring
declare function Whex ( byval number as ulong ) as wstring
declare function Whex ( byval number as ulongint ) as wstring
declare function Whex ( byval number as const any ptr ) as wstring

declare function Whex ( byval number as ubyte, byval digits as long ) as wstring
declare function Whex ( byval number as ushort, byval digits as long ) as wstring
declare function Whex ( byval number as ulong, byval digits as long ) as wstring
declare function Whex ( byval number as ulongint, byval digits as long ) as wstring
declare function Whex ( byval number as const any ptr, byval digits as long ) as wstring

用法

result = Whex( number [, digits ] )

参数

number

整数或计算结果为整数的表达式。

digits

可选的返回位数。

返回值

返回 number 的十六进制 wstring 表示,如果指定了位数,则截断或用零("0")左填充以符合指定位数。

说明

十六进制位范围为 0-9A-F

如果指定 digits > 0,结果 wstring 将恰好为该长度。如有必要,将从左侧截断或用零填充。

wstring 的长度不会超过 expression 类型所需的最大位数(long 为 8 位,浮点数或 longint 为 16 位)。

示例

start GeSHi

vb
Print Hex(54321)
Print Hex(54321, 2)
Print Hex(54321, 5)

end GeSHi

将产生如下输出:

D431
31
0D431

平台差异

  • FreeBASIC 的 DOS 移植版本不支持 Unicode 字符串。

方言差异

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

与QB的区别

  • FreeBASIC 新增。

参见

  • Hex
  • Wbin
  • Woct

返回 目录

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