java 16进制 转 10进制 工具类分享

package com.hl.dziot.util;

import java.util.HashMap;
import java.util.Map;

/**
* 转换工具类
*
* @author hwx
* @date 2023/6/7
**/
public class ConverUtils {
/**
* 16进制 转 10进制
* @author hwx
*/
public static int covert(String content){
int number=0;
String [] HighLetter = {"A","B","C","D","E","F"};
Map<String,Integer> map = new HashMap<>();
for(int i = 0;i <= 9;i++){
map.put(i+"",i);
}
for(int j= 10;j<HighLetter.length+10;j++){
map.put(HighLetter[j-10],j);
}
String[]str = new String[content.length()];
for(int i = 0; i < str.length; i++){
str[i] = content.substring(i,i+1);
}
for(int i = 0; i < str.length; i++){
number += map.get(str[i])*Math.pow(16,str.length-1-i);
}
return number;
}
}
 
posted @   jiuchengi  阅读(267)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示