0x开头的16进制没有负数与小数
private double hexconvertodouble(string hexstring) 【程序编程相关:关于msdn上面的《Web 窗体页创建分】
#region change hex to double 【推荐阅读:测试工作总体流程图 】
if (hexstring == "") 【扩展信息:ActionForm的生命周期浅探】
{
{
return 0;
}
string data;
if (hexstring.startswith("0x"))
{
data = hexstring.substring(2);
}
else
{
data = hexstring;
}
char[] eachdata = data.tochararray();
double result = 0;
for (int i = 0; i < eachdata.length; i++)
{
char charvalue = eachdata[i];//eachdata[m];
double x = 16;//如果是八进制则写成8就可以
double y = system.convert.todouble(eachdata.length - i - 1);
switch (charvalue)
{
case ´0´:
break;
case ´1´:
result += 1 * math.pow(x,y);
break;
case ´2´:
result += 2 * math.pow(x,y);
break;
case ´3´:
result += 3 * math.pow(x,y);
break;
case ´4´:
result += 4 * math.pow(x,y);
break;
case ´5´:
result += 5 * math.pow(x,y);
break;
case ´6´:
result += 6 * math.pow(x,y);
break;
... 下一页