NumPy 中的 右移运算符函数

首页 / Numpy入门教程 / NumPy 中的 右移运算符函数

numpy.right_shift()函数将数组元素的二进制表示形式向右移动指定的位置,并在左侧添加相等数量的0。

import numpy as np 

print 'Right shift 40 by two positions:' 
print np.right_shift(40,2) 
print '\n'  

print 'Binary representation of 40:' 
print np.binary_repr(40, width=8) 
print '\n'  

print 'Binary representation of 10' 
print np.binary_repr(10, width=8)  
# Two bits in '00001010' are shifted to right and two 0s appended from left.

其输出如下-

无涯教程网

Right shift 40 by two positions:
10

Binary representation of 40:
00101000

Binary representation of 10
00001010

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

从0开始学架构 -〔李运华〕

移动端自动化测试实战 -〔思寒〕

数据中台实战课 -〔郭忆〕

陈天 · Rust 编程第一课 -〔陈天〕

攻克视频技术 -〔李江〕

技术领导力实战笔记 2022 -〔TGO 鲲鹏会〕

B端体验设计入门课 -〔林远宏(汤圆)〕

结构写作力 -〔李忠秋〕

互联网人的数字化企业生存指南 -〔沈欣〕

好记忆不如烂笔头。留下您的足迹吧 :)