Home  >  Article  >  Backend Development  >  10进制负数 转 16进制

10进制负数 转 16进制

WBOY
WBOYOriginal
2016-06-23 14:23:581476browse

-101 结果 9b

PHP怎么写?


回复讨论(解决方案)

echo dechex(-101);
如要得到9b,需要忽略前面的ff,因为是负数。

echo dechex(-101 & 0xff); //9b

echo dechex(-101);
如要得到9b,需要忽略前面的ff,因为是负数。



echo dechex(-101 & 0xff); //9b


非常感谢~~

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
Previous article:如何进行身份验证Next article:过滤空格,急在线等