无符号变量和有符号变量的区别深圳

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/24 20:10:55
无符号变量和有符号变量的区别深圳
xSAc1Qz*35'Kn"փ.AzY!Šg25=]9 tSޫznc9?+'ˣjtfIyVgŗt亣` ":#nDRTI cH(!cuPRWCF6(T v,:SH9PڡZ OwKȵN !E@tGd!Fg†R! Ynݣ15S\:L- Q$hp$/"!=*.Z`iA7<'0 N3,0 bqFM%d l!un$Pۜؖ!,60L+mf/݄kv-4AQ#DyOH9ڋR4"U ωoWEX"Z

无符号变量和有符号变量的区别深圳
无符号变量和有符号变量的区别深圳

无符号变量和有符号变量的区别深圳
In C/C++ and some other language (e.g.Java),integers r stored in the memory using 2's complement notation.
For positive integers,their 2's complement notation is of no difference from their binary representation.
Negative integers r slightly more complicated.To achieve their 2's complement notation,u can:
1.get the binary representation of its absolute value;
2.add 1 to that representation.
Of course,there're restrictions of limited memory space.
In this way,negative integers r stored in the memory in quite a same way as positive ones.
e.g.1111 1111 = -1;
However,for a unsigned integer,it is assumed that no negative integers r stored,i.e.all the numbers r stored using their binary representation.In this case,1111 1111 = 255.
看不懂的话补充说明或者叫我翻译.