Home  >  Article  >  Backend Development  >  10进制负数 转 16进制,该怎么解决

10进制负数 转 16进制,该怎么解决

WBOY
WBOYOriginal
2016-06-13 11:46:331856browse

10进制负数 转 16进制
-101 结果 9b

PHP怎么写?
------解决方案--------------------
echo dechex(-101);
如要得到9b,需要忽略前面的ff,因为是负数。
------解决方案--------------------
echo dechex(-101 & 0xff); //9b

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn