From -2107315184582059508
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8d9af67f0c48e4ef
X-Google-Attributes: gidf78e5,public
X-Google-Thread: fc772,8d9af67f0c48e4ef
X-Google-Attributes: gidfc772,public
X-Google-ArrivalTime: 2002-04-30 09:52:08 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!denver-snf1.gtei.net!news.gtei.net!namche.sun.com!news2me.EBay.Sun.COM!engnews1.eng.sun.com!taumet!clamage
From: "P.J. Plauger" <pjp@dinkumware.com>
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: Re: Unsignedness of size_t
Date: 29 Apr 2002 21:49:25 GMT
Organization: unknown
Lines: 62
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <3ccd58e5$0$20934$4c41069e@reader1.ash.ops.us.uu.net>
References: <3CC7DB8F.52E75D62@bawi.org>
NNTP-Posting-Host: taumet.eng.sun.com
X-NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: Mon, 29 Apr 2002 10:30:19 -0400
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAPM22kEHMCo9UcraBAQFMQQIAjxR5Two3kfP9u2xijvH69lLZpjJVyM6z
	jqVaQxo38DCJMBq/QS8+FjrFYRPWx704PqKrJMkX3ox50zxsZgnh5Q==
	=ryBH
X-Approved-For-Group: jep@[151.161.11.6] comp.lang.c++.moderated
X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang)
Content-Length: 2390
X-Status: $$$$
Originator: clamage@taumet
Xref: archiver1.google.com comp.std.c++:10905 comp.lang.c++.moderated:42394


"Sungbom Kim" <musiphil@bawi.org> wrote in message
news:3CC7DB8F.52E75D62@bawi.org...

> I often find it somewhat "flawed" that the standard requires the data
> type representing sizes of objects to be an unsigned integral type.

I don't.

> They are just arithmetic quantities, like 'number of people'; no one
> would recommend using unsigned numbers for those kind of quantities.

Really? I would. And I usually do, in my own code.

> They have semantics of neither modular arithmetics nor bit arrays.
> As Stroustrup mentioned in TC++PL 4.4, usage of unsigned integer types
> for that kind of situation is discouraged.

By whom? Not by me.

>                                            It also causes many problems
> in arithmetics mixed with signed integers.

It is true that ``unsigned'' in C/C++ is really modulus arithmetic.
Since neither language has a non-negative type, unsigned is the closest
you can get. Indeed, I usually find it a better match than signed.

Since the C Standard chose value-preserving promotion rules over
unsigned-preserving, I have had few occasions where mixed arithmetic
causes any real problems. The usual problem I see is busybody compilers
that insist on warning that an operation *might* be dangerous -- the
problem is that I have to add type casts to avoid customer complaints
about warning messages.

Java chose to deep six all the unsigned types. As a result, I've had
to play ugly games in several places when writing the Java library.
When you need unsigned arithmetic, you really need it.

> I know that it is from C and that it's too late to change anything,
> but I just want to hear what others have to say.

You just did. In fairness, I have to confess that I'm the person who
proposed the introduction of size_t as an unsigned type into Standard
C. And I also fought hard for the VP rules over UP ones. So I'm
doubtless biased in this area.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com




      [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]




