Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

numbers - Hexadecimal to decimal

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:

a hexadecimal number from AutoIt's documentation

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?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As per Documentation - Language Reference - Datatypes:

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.

Issuing:

ConsoleWrite(0x00200000 & @LF)

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

Related functions include:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...