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

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

技术教程推荐

赵成的运维体系管理课 -〔赵成〕

重学前端 -〔程劭非(winter)〕

Linux实战技能100讲 -〔尹会生〕

黄勇的OKR实战笔记 -〔黄勇〕

架构实战案例解析 -〔王庆友〕

大厂广告产品心法 -〔郭谊〕

JavaScript进阶实战课 -〔石川〕

结构执行力 -〔李忠秋〕

结构思考力 · 透过结构看思考 -〔李忠秋〕

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