什么是">>>"在java中是什么意思 [英] What does ">>>" in java mean?
问题描述
我试图将此代码转换为python,但我很难这样做,不要担心索引值和变量名称,我只是想知道>>>部分究竟做了什么,也许一个python等价物,但解释会很棒:
im trying to translate this code to python, but im having a hard time doing so, don't worry about the index values and variable names, I just want to know what the ">>>" part does exactly, perhaps a python equivalent, but an explanation would be great:
target[0] = (char)(source[sourceIndex] >>> 2);
target[1] = (char)((source[sourceIndex] & 3) << 4 | source[sourceIndex + 1] >>> 4);
target[2] = (char)((source[sourceIndex + 1] & 0xf) << 2 | source[sourceIndex + 2] >>> 6);
target[3] = (char)(source[sourceIndex + 2] & 0x3f);
任何帮助将不胜感激
推荐答案
<<<<<和>>是位移操作符。具体来说,
The "<<<" and ">>" are bit shift operators. Specifically,
签名的左移运算符<<将位模式向左移位,带符号的右移位运算符>>将位模式向右移位。位模式由左侧操作数给出,以及由右侧操作数移位的位置数。无符号右移运算符>>>将零移至最左侧位置,而>>后最左侧位置取决于符号扩展。
The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.
这篇关于什么是">>>"在java中是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!