Richard Heathfield wrote:

> [...] Think of

> (heretical!) three-bit ints, with the first of them being the sign bit:

>

> Bit pattern Unsigned value Signed value

> 000 0 0

> 001 1 1

> 010 2 2

> 011 3 3

>

> All remaining values must have the high bit set, and thus must be negative

> in a signed type (irrespective of whether it's ones' complement, two's

> complement, or sign-and-mag).
100 could be zero, which is not negative:

if (minus_zero < 0 || minus_zero > 0 || minus_zero != 0) {

puts("This isn't C!");

puts("(Or else minus zero is a trap representation,\n"

"and you're only seeing this as a consequence\n"

"of undefined behavKUHYTDjn;lkUy97609i]*&^%$");

}

Although the example is flawed, the O.P.'s supposition is

correct: If the set of values is not symmetrical about zero,

the "extra" value must be negative:

- Signed magnitude: The "extra" encoding is 10...0, which

is either "minus zero" or a trap representation. Even if

"minus zero" is allowed, its value is zero so the range

is symmetrical.

- Ones' complement: The "extra" encoding is 11...1, which

is either "minus zero" or a trap. As before, the range is

symmetrical.

- Two's complement: The "extra" encoding is 10...0, which

is either minus two-to-the-Nth or a trap. If it's a trap

the range is symmetrical; otherwise, the range is

asymmetrical and the "extra" value is negative.

That covers all the representations permitted by the Standard,

and the only case in which the range is asymmetrical has more

negative than positive values.

--

Eric Sosman

http://www.velocityreviews.com/forums/(E-Mail Removed)lid