十六进制到十进制

编程入门 行业动态 更新时间:2024-10-26 08:20:27
本文介绍了十六进制到十进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我必须将十六进制数转换为十进制数,但不知道如何。在AutoIt文档中(如下图所示),定义了一些常量(被指定为十六进制值):

$ b $ p $ 0x00200000 十六进制(图中带下划线)等于 8192 decimal(这是真正的转换)。但是转换器返回 2097152 。我必须转换另一个十六进制值( 0x00000200 ),但转换器错误。如何正确转换它?

当我使用定义 $ WS_EX_CLIENTEDGE (或一个十六进制值)时,它不会没有工作。如果我使用一个整数,我相信它会起作用。

解决方案

文档 - 语言参考 - 数据类型:

在AutoIt中,只有一种数据类型称为Variant。变量可以包含数字或字符串数​​据,并根据使用情况决定如何使用数据。

发行:

ConsoleWrite(0x00200000& @LF)

显示陈述的行为。使用 Int() 在转换要求的情况下:

#region Hex2Dec 全局常量$ 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

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 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.

解决方案

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

更多推荐

十六进制到十进制

本文发布于:2023-10-09 10:32:03,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:十六进制到十进制

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!