如何转换进制中的ActionScript3为十进制?

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

如何转换十六进制(字符串),以十进制(INT)中的ActionScript3?

How to convert hex(in string) to decimal(int) in Actionscript3?

推荐答案

数, INT 和 UINT 类有的toString()方法,它接受基数作为参数。

Number, int and uint class having toString() method which accept radix as arguments.

基数指定数字的基数(从2到36)用于数字到字符串的转换。如果不指定基数参数,默认值是10。

radix Specifies the numeric base (from 2 to 36) to use for the number-to-string conversion. If you do not specify the radix parameter, the default value is 10.

您可以转换像八进制,十六进制,二进制数,通过和uint类中的任何位置。

you can convert to any base like octal, hex, binary via Number and uint class.

更好的办法

VAR十进制:INT = parseInt函数(FFFFFF,16); //输出:16777215

var decimal:int = parseInt("FFFFFF",16); // output : 16777215

另一种方式

var hex:String = "0xFFFFFF";

VAR hexint:INT = INT(十六进制); //输出:16777215

var hexint:int = int(hex); // output : 16777215

就相当于

VAR hexint:INT = INT(十六进制)的ToString(10); //十进制转换

回到最初值:

var decimalStr:String = hexint.toString(16).toUpperCase(); // output : FFFFFF

更多推荐

如何转换进制中的ActionScript3为十进制?

本文发布于:2023-11-23 15:35:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621972.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进制中   十进制

发布评论

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

>www.elefans.com

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