Velocity Reviews > Range of short int?

# Range of short int?

Tim Rentsch
Guest
Posts: n/a

 12-28-2005
Keith Thompson <(E-Mail Removed)> writes:

> "Malcolm" <(E-Mail Removed)> writes:
> [...]
> > If you want to treat a short as an abstract integer, rather than a series of
> > bits, the obvious reason is so that you are not tied to two's complement
> > representation.
> > Therefore you need to follow the standard, which guarantees the range -32767
> > to + 32767 only. (-32768 might be used as a trap representation, for
> > example, or the machine might be one's complement, or use a weird and
> > wonderful system not yet devised).

>
> C99 6.2.6.2 limits the possibilites to two's complement, ones'
> complement, and sign and magnitude. (Yes, the placement of the
> apostrophes is correct.)

Just curious - do you have any idea why the writing of (only) one of
these terms changed between C99 and n1124? Surely it would be better
if the two terms were written consistently; anyone have any idea why
they aren't?

Eric Sosman
Guest
Posts: n/a

 12-28-2005
Tim Rentsch wrote:

> Keith Thompson <(E-Mail Removed)> writes:
>
>
>>"Malcolm" <(E-Mail Removed)> writes:
>>[...]
>>
>>>If you want to treat a short as an abstract integer, rather than a series of
>>>bits, the obvious reason is so that you are not tied to two's complement
>>>representation.
>>>Therefore you need to follow the standard, which guarantees the range -32767
>>>to + 32767 only. (-32768 might be used as a trap representation, for
>>>example, or the machine might be one's complement, or use a weird and
>>>wonderful system not yet devised).

>>
>>C99 6.2.6.2 limits the possibilites to two's complement, ones'
>>complement, and sign and magnitude. (Yes, the placement of the
>>apostrophes is correct.)

>
>
> Just curious - do you have any idea why the writing of (only) one of
> these terms changed between C99 and n1124? Surely it would be better
> if the two terms were written consistently; anyone have any idea why
> they aren't?

Detail-oriented readers and copy editors should notice the
position of the apostrophe in terms like "two's complement" and
"ones' complement": A two's complement number is complemented
with respect to a single power of 2, while a ones' complement
number is complemented with respect to a long sequence of 1s.
Indeed, there is also a "twos' complement notation," which has
radix 3 and complementation with respect to (2...22)_3.

-- D.E. Knuth, "The Art of Computer Programming, Volume II:
Seminumerical Algorithms" (third edition) section 4.5.

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

lawrence.jones@ugs.com
Guest
Posts: n/a

 01-01-2006
Tim Rentsch <(E-Mail Removed)> wrote [re. ones' and two's complement]
>
> Just curious - do you have any idea why the writing of (only) one of
> these terms changed between C99 and n1124? Surely it would be better
> if the two terms were written consistently; anyone have any idea why
> they aren't?

<http://en.wikipedia.org/wiki/Talk:Signed_number_representations>

-Larry Jones

I'll be a hulking, surly teen-ager before you know it!! -- Calvin