我试图在这里找到答案,但是没有找到。
“ >>”和“ <<”在python中是什么意思?
解释器中的示例:
In [9]: 23 >> 64
Out[9]: 0
In [10]: 23 << 64
Out[10]: 424275113695319687168L
In [11]: 1 >> 2
Out[11]: 0
In [12]: 32132345235423451 >> 2
Out[12]: 8033086308855862
In [13]: 321323452354566423451 >> 2
Out[13]: 80330863088641605862L
In [14]: 2 >> 2
Out[14]: 0
In [15]: 233 >> 2
Out[15]: 58
In [16]: 33 >> 2
Out[16]: 8
In [17]: 3 >> 2
Out[17]: 0
<<
和>>
分别是Binary Left Shift和Binary Right Shift。
左操作数的值向左移动右操作数指定的位数。
示例,代码: temp = 14 << 2
The variable temp has a value of 56 because 14 (00001110 in binary) shifted left two bits equals 56 (00111000 in binary).
左操作数的值向右移动右操作数指定的位数。
示例,代码: temp = -14 >> 2 temp has a value of -4: -14 (11110010 in two's complement binary) shifted right two bits equals -4 (11111100 in two's complement binary).
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句