(1 <29)是最大整数? [英] Is (1&lt;&lt;29) the biggest integer?

查看:153
本文介绍了(1 <29)是最大整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1<< 29.这是什么意思?

i知道它的按位操作吗?



我尝试了什么:



1<<29.what does this mean?
i know its bitwise operation?

What I have tried:

and why is it defined?



1< < 29。这可能是最大的整数?


1<<29.how this can be biggest integer?

推荐答案

是的,这是一个明智的操作:
Yes, it's a bit wise operation:
x << y

将x向左移动y位。

moves x to the left by y bits.

x  y  x << y  binary
1  1  2       000010 
2  1  4       000100 
1  3  8       001000
...

所以

1 << 29

是一个向左移动29位。如果你愿意,一个后跟29个二进制零,或536,870,912,它远不及有符号32位整数中最大可能值:2,147,483,647或01111111111111111111111111111111二进制。

is one moved 29 bits to the left.or if you prefer, a one followed by 29 zeros in binary, or 536,870,912 which is nowhere near the largest possible value in a signed 32 bit integer: 2,147,483,647 or 01111111111111111111111111111111 in binary.


对于32位有符号整数,最大[正]值为(1 <<< 31 ) - 1 (因为 1<<< 31 代表最小[负]值),或 2 147 483 647



对于32位无符号整数,最大值为 (1 << 32) - 1 (最小值为0),或 4 294 967 295



类似:



对于64位签名整数,最大值为(1 <<<<<<<<<" 63) - 1 (因为 1<<< 63 代表最小[负]值),或者 9 223 372 036 854 775 807



对于64位无符号整数,m最大值是(1 << 64) - 1 ,或 18 446 744 073 709 551 615



也许这将有助于您理解二元转换操作:

算术转换 - 维基百科 [ ^ ]
For a 32-bits signed integer, the maximum [positive] value is (1 << 31) - 1 (because 1 << 31 represents the minimum [negative] value), or 2 147 483 647.

For a 32-bits unsigned integer, the maximum value is (1 << 32) - 1 (minimum value being 0), or 4 294 967 295.

Similarly:

For a 64-bits signed integer, the maximum value is (1 << 63) - 1 (because 1 << 63 represents the minimum [negative] value), or 9 223 372 036 854 775 807.

For a 64-bits unsigned integer, the maximum value is (1 << 64) - 1, or 18 446 744 073 709 551 615.

Maybe this will help you understanding binary shifting operations:
Arithmetic shift - Wikipedia[^]


这篇关于(1 <29)是最大整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆