Java 十六进制转十进制
2024-08-20 17:29:28
public static int hexToDecimal(String hex) {
int decimalValue = 0;
for (int i = 0; i < hex.length(); i++) {
decimalValue = decimalValue * 16 + hexCharToDecimal(hex.charAt(i));
}
return decimalValue;
}
public static int hexCharToDecimal(char ch) {
if (ch <= 'F' && ch >= 'A') {
return 10 + ch - 'A';
}
else {
return ch - '0';
}
}
System.out.println("The decimal number for hex " + hexString
+ " is " + hexToDecimal(hexString.toUpperCase()));
最新文章
- Mybatis关联查询和数据库不一致问题分析与解决
- UWP 判断windows mobile是使用的实体键还是虚拟按键
- 简述cookie
- .NET面试题解析(00)-开篇来谈谈面试 &; 系列文章索引
- Hyperledger智能合约Hello World示例程序
- APP UI设计相关的一些链接
- umbraco使用VS安装
- MessageBox.Show()如何换行
- bzoj2466: [中山市选2009]树
- vs2012+cmake+opencv+opencv unable to find a build program corresponding to ";Visual Studio 12 Win64";. CMAKE_MAKE_PROGRAM is not set
- iOS Runtime 实践(1)
- 关于Daydream VR的最直白的介绍
- codeforces 616E. Sum of Remainders 数学
- IOS9.0 之后友盟分享详细过程
- /etc/fstab 文件挂载配置文件
- EZ 2018 06 02 NOIP2018 模拟赛(十七)
- 自动化脚本编写环境部署_win7(RF)
- XMLHttpRequest 的使用&;#183;&;#183;&;#183;&;#183;&;#183;&;#183;
- 6. 集成学习(Ensemble Learning)算法比较
- 前端基础进阶之Promise
热门文章
- ORA-00214: control file 控制文件版本不一致
- c++ 读取并解析excel文件方法
- 五指CMS发布,主打高性能
- 《Android View 的事件分发和滑动冲突》 —预习资料
- Kafka系列(一)安装和配置说明
- Xcode部分插件无法使用识别的问题
- Java和.NET的GZIP压缩功能对比
- 为Android安装BusyBox
- 解决libpython2.6.so.1.0: cannot open shared object file
- 用document.title=“xxx”动态修改title,在ios的微信下面不生效