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

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

技术教程推荐

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

安全攻防技能30讲 -〔何为舟〕

分布式系统案例课 -〔杨波〕

Python自动化办公实战课 -〔尹会生〕

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

Tony Bai · Go语言第一课 -〔Tony Bai〕

网络排查案例课 -〔杨胜辉〕

手把手教你落地DDD -〔钟敬〕

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

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