|
From: Per W. <pw...@ia...> - 2006-06-09 13:15:59
|
Actually, the two-complement format (that only stores one zero) uses the extra value to store an extra negative value. A two-bit signed integer would store the values -2, -1, 0, 1. /Per W On Fri, 9 Jun 2006, [ISO-8859-15] G=F6sta Ljungdahl wrote: > One bit is consumed by the sign (+ or -) which means that if the > variable is signed it's maximum absolute value is "about" half that of a > corresponding unsigned variable. An example explained the "about": > Two bit integer > 00 01 10 11 > > unsigned > this would be: > 0 1 2 3 > > signed > assuming MSB contains the sign and + <-> 1 this would be: > -0 -1 +0 +1 but since we only need one zero one normally does something > like this: > -1 0 +1 +2 that is -0 is taken to mean +2 and +0 is taken to mean 0 > hence the "about". > > > > > > > Erik Schmidt skrev: > > what's the difference between a signed and unsigned variable > > > > > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |