PHP右移 [英] PHP shift right

查看:111
本文介绍了PHP右移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我试图在PHP实现DataOutputStream类
(DataOutputStream类从Java语言)
在java中code,他们右移变量,像这样>>>

hey there i am trying to implement DataOutputStream in php (DataOutputStream from java language) in java code they shift right variables like this >>>

在PHP我只能转向像这样>>

in php i can only shift like this >>

我怎样才能做到这一点在PHP?

how can i do this in php ?

感谢您

推荐答案

可以的实施无符号向右移位运算符的行为>>> 通过签订移位运算符是这样的:

You can implement the behavior of the unsigned right shift operator >>> with the signed shift operators like this:

的值 N'GT;>> S N 右移与零扩展s 位的位置。如果 N 为正,那么结果是一样的为n>> S ;如果 N 为负,其结果是等于前pression (N>&GT S)的+(2';< 〜S)如果左侧操作数的类型的 INT 的,并且到EX pression (N&GT的结果;&GT S)+(2L<<〜S)如果左侧操作数的类型的的。增加的长期(2';<〜S)(2L<<〜S)抵消了传​​播符号位。

The value of n>>>s is n right-shifted s bit positions with zero-extension. If n is positive, then the result is the same as that of n>>s; if n is negative, the result is equal to that of the expression (n>>s)+(2<<~s) if the type of the left-hand operand is int, and to the result of the expression (n>>s)+(2L<<~s) if the type of the left-hand operand is long. The added term (2<<~s) or (2L<<~s) cancels out the propagated sign bit.

这篇关于PHP右移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆