Home  >  Article  >  Backend Development  >  PHP 按位取反的问题

PHP 按位取反的问题

WBOY
WBOYOriginal
2016-06-23 14:20:341518browse

现在有一串数字,
$str=1300022332121
要求按位取反该怎么弄
这个按位取反,跟其他程序的按位取反,有不同之处吗
因为我是要能够将他传给C++写的程序的,
请各位大侠执教


回复讨论(解决方案)

$str=1300022332121;echo ~$str; //2147483647

PHP位运算符

取反的操作任何语言都是一样的吧。

没有那么简单

你的C++要求传入的是什么?

1300022332121 已经超出了 unsigned long 可表示的范围了

php的取反运算符不好理解,可以这样记忆:~0=-1;~1=-2......~5=-6,参考资料: http://www.ibihuo.com/show-63.html

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