We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-------------------------------------------- | c声明 | 字节数 | -------------------------------------------- | 有符号 | 无符号 |32位 | 64位| -------------------------------------------- | char | unsigned char | 1 | 1 | -------------------------------------------- | short | unsigned short | 2 | 2 | -------------------------------------------- | int | unsigned | 4 | 4 | -------------------------------------------- | long | unsigned long | 4 | 8 | -------------------------------------------- | int32_t | uint32_t | 4 | 4 | -------------------------------------------- | int64_t | uint64_t | 8 | 8 | -------------------------------------------- | char * | | 4 | 8 | -------------------------------------------- | float | | 4 | 4 | -------------------------------------------- | double | | 8 | 8 | --------------------------------------------
上学时候老师讲补码都是对某个值的原码求反加1. 比如+2是010,那么-2就是101 + 1 == 110。可是补码的这个补代表什么呢?其实
+2
010
-2
101 + 1 == 110
-2 = 2^3 - 2
上面-2用3个bit表示,补码表达的就是补充到2^ 3需要的值的大小 csapp里面给出了使用补码带来的两个好处
3
2^ 3
+0
-0
00
-128
+1 -3
0001 + 1101 = 1110
The text was updated successfully, but these errors were encountered:
No branches or pull requests
信息存储
字数据大小
面试问题
为什么计算机用补码表示整数,而不是反码或者原码
上学时候老师讲补码都是对某个值的原码求反加1. 比如
+2
是010
,那么-2
就是101 + 1 == 110
。可是补码的这个补代表什么呢?其实上面
-2
用3
个bit表示,补码表达的就是补充到2^ 3
需要的值的大小csapp里面给出了使用补码带来的两个好处
+0
和-0
在补码的表示中都是00
,这带来了一致性。另外可以表达-128
+1 -3
, 相当于0001 + 1101 = 1110
。也就是-2
The text was updated successfully, but these errors were encountered: