NumPy 中的 左移运算符函数

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

numpy.left_shift()函数将数组元素的二进制向左移动指定位置,从右边追加等号0。

import numpy as np 

print 'Left shift of 10 by two positions:' 
print np.left_shift(10,2) 
print '\n'  

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

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

其输出如下-

无涯教程网

Left shift of 10 by two positions:
40

Binary representation of 10:
00001010

Binary representation of 40:
00101000

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

技术教程推荐

硅谷产品实战36讲 -〔曲晓音〕

趣谈网络协议 -〔刘超〕

NLP实战高手课 -〔王然〕

检索技术核心20讲 -〔陈东〕

流程型组织15讲 -〔蒋伟良〕

高并发系统实战课 -〔徐长龙〕

手把手带你搭建推荐系统 -〔黄鸿波〕

超级访谈:对话道哥 -〔吴翰清(道哥)〕

云原生基础架构实战课 -〔潘野〕

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