Home  >  Article  >  Backend Development  >  怎么将二进制数转为有符号整数

怎么将二进制数转为有符号整数

WBOY
WBOYOriginal
2016-06-13 12:04:161967browse

如何将二进制数转为有符号整数
RT,现有1字节二进制数,想转换成8位有符号整数。请问有这样功能的函数吗?hexdec是无符号的。。
------解决方案--------------------
如果你的 $a 是这样来的:$a = bin2hex($b);
那么就

$ar = unpack('c*', $b);

这样就把 $b 按字节转换成用符号整数数组了

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