按位移位? [英] bitwise shift?
问题描述
我找到了这个循环的代码示例。
表示范围内的k(10,25):
n = 1<< k;
我以前从未读过Python,但是正确的是1乘以
与数字10,11,12,12,...,25假设1<< k表示1班次
留下k这与乘以k相同。
I have found a code example with this loop.
for k in range(10, 25):
n = 1 << k;
I have never read Python before but is it correct that 1 get multiplied
with the numbers 10,11,12,12,...,25 assuming that 1 << k means "1 shift
left by k" which is the same as multiplying with k.
推荐答案
desktop写道:
desktop wrote:
I已经找到了这个循环的代码示例。
范围内的k(10,25):
n = 1<< k;
我之前从未读过Python,但是1乘以
与数字10,11,12,12,...是正确的... ,25
I have found a code example with this loop.
for k in range(10, 25):
n = 1 << k;
I have never read Python before but is it correct that 1 get multiplied
with the numbers 10,11,12,12,...,25
No.
No.
假设1<< k表示由k左移1。
assuming that 1 << k means "1 shift left by k"
是。
Yes.
与乘以k相同。
which is the same as multiplying with k.
No.
尝试启动Python解释器并输入1<< 10.
-
Michael Hoffman
No.
Try starting the Python interpreter and entering 1 << 10.
--
Michael Hoffman
desktop schrieb:
desktop schrieb:
我找到了这个循环的代码示例。
表示范围内的k(10,25):
n = 1< < k;
我之前从未读过Python,但是1乘以
与数字10,11,12,12,...是正确的...假设1 << k表示1班次
留下k这与乘以k相同。
I have found a code example with this loop.
for k in range(10, 25):
n = 1 << k;
I have never read Python before but is it correct that 1 get multiplied
with the numbers 10,11,12,12,...,25 assuming that 1 << k means "1 shift
left by k" which is the same as multiplying with k.
1<< n
是一个更有效的替代品
2 ** n
Thomas
-
sinature: http:// nospam。 nowire.org/signature_usenet.png
desktop< ff*@sss.comwrites:
desktop <ff*@sss.comwrites:
$ b范围内的k为$ b(10,25):
n = 1<< k;
之前我从来没有读过Python但是1是否正确#b $ b乘以数字10,11,12,12,这是正确的...假设1 << k
表示由K左移1次这与乘以k相同。
for k in range(10, 25):
n = 1 << k;
I have never read Python before but is it correct that 1 get
multiplied with the numbers 10,11,12,12,...,25 assuming that 1 << k
means "1 shift left by k" which is the same as multiplying with k.
左移+ *与乘以k相同。它与2 ^ k的多元/ b $ b相同。即,1 << 10 = 1024,1 << 11 = 2048,1 << 12 = 4096等。
sherm--
-
West Virginians的网页寄存,西弗吉尼亚人: http://wv-www.net
Perl中的Cocoa编程: http://camelbones.sourceforge.net
这篇关于按位移位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!