本文介绍了如何在Java中减去或添加两个十六进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以计算两个十六进制值而不将其转换为int?例如
:
Is there a way of calculating two hexadecimal value without converting it to int?for example:
String sHex = "f7c0";
String bHex = "040000000";
推荐答案
十六进制值是整数-用十六进制表示,而不是十进制。
Hexadecimal values are integers - just represented in hex instead of decimal.
您不能这样做吗?
int sHex = 0xf7c0;
int bHex = 0x040000000;
如果不是,那么您实际上的意思是:
If not, then you actually meant:
String sHex = "f7c0";
String bHex = "040000000";
在这种情况下,最快的方法仍然是将它们转换为整数,例如 Integer.parseInt(sHex,16);
In which case, the fastest way to do this is still by converting them to integers, using something like Integer.parseInt(sHex, 16);
这篇关于如何在Java中减去或添加两个十六进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!