The range of signed int is - 2^15 to + (2^15 )-1 (-32768 to 32767) Whythe one less at positive Range ? (compared to the negative side..!)I came to know that it uses 2''s compliment internally for storing thenegative numbers . why it uses 2''s compliment but not the ones complimentfor storing the negative numbers ? 解决方案This is entirely dependent on the machine / implementation.And ansi C does not have any say on this.--Karthik.The C language permits a 1''s complement or sign-magnitude representationof signed integers in addition to 2''s complement. Your compiler uses 2''scomplement almost certainly because that is what the processor it istargetting uses. Modern processors tend to use 2''s complement because ithas some nice properties and can simplify the hardware design (e.g. youcan avoid separate instructions for signed and unsigned addition andsubtraction). An obvious issue with 1''s complement and sign-magnitude is2 separate representations for the number zero.Lawrence 这篇关于为什么Int的范围在正面较少??.........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-05 17:38