我正在尝试将十六进制转换为八进制,就像在C#中的excel一样。
在普通转换器中:
=Hex2Oct("FFF0FFFFFF")
Answer:17776077777777
在Excel中:
=Hex2Oct("FFF0FFFFFF")
Answer:6077777777
我怎么能解决这个问题 有人知道请建议我吗?
答案 0 :(得分:0)
Excel 截断结果,因此它不正确;根据手册
- If number is negative, it cannot be less than FFE0000000,
and if number is positive, it cannot be greater than 1FFFFFFF.
...
所以你的论点(“FFF0FFFFFF”)超出了范围。
示例C#代码
private static String Hex2Oct(String value) {
// Assuming that given value is short enough to be represented as Int64
return Convert.ToString(Convert.ToInt64(value, 16), 8);
}
...
Console.Write(Hex2Oct("FFF0FFFFFF")); // 17776077777777