十六进制转十进制 [英] Hexadecimal to decimal
问题描述
我必须将十六进制数转换为十进制数,但不知道如何操作.在 AutoIt 文档(如下图)中定义了一些常量(被分配了十六进制值):
I have to convert a hexadecimal number to decimal, but don't know how. In the AutoIt documentation (pictured below) some constants (being assigned hexadecimal values) are defined:
0x00200000
十六进制(图像中有下划线)等于 8192
十进制(这是真正的转换).但是转换器返回2097152
.我必须转换另一个十六进制值 (0x00000200
),但转换器弄错了.如何正确转换?
0x00200000
hexadecimal (underlined in image) equals 8192
decimal (this is the true conversion). But convertors return 2097152
. I have to convert another hex value (0x00000200
), but convertors get it wrong. How to correctly convert it?
当我使用定义 $WS_EX_CLIENTEDGE
(或十六进制值)时,它不起作用.如果我使用整数,我相信它会起作用.
When I use the definition $WS_EX_CLIENTEDGE
(or a hexadecimal value), it doesn't work. If I use an integer I believe it will work.
推荐答案
根据 文档 - 语言参考 - 数据类型:
在 AutoIt 中,只有一种数据类型称为 Variant.一个变体可以包含数字或字符串数据并决定如何使用数据取决于它的使用情况.
In AutoIt there is only one datatype called a Variant. A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in.
发行:
ConsoleWrite(0x00200000 & @LF)
展示声明的行为.使用 Int()
以防万一转换要求:
demonstrates stated behavior. Use Int()
in case of conversion requirement:
#region Hex2Dec
Global Const $dBin1 = 0x00200000
Global Const $iInt1 = Int($dBin1)
ConsoleWrite($iInt1 & @LF)
#endregion
#region Dec2Hex
Global Const $iInt2 = 8192
Global Const $dBin2 = Hex($iInt2)
ConsoleWrite('0x' & $dBin2 & @LF)
#endregion
相关功能包括:
Int()
Number()
String()
StringToBinary()
StringToASCIIArray()
StringFromASCIIArray()
Binary()
BinaryToString()
Ptr()
HWnd()
这篇关于十六进制转十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!