From 8432079745375857984
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-05-01 13:42:09 PST
Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.online.be!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!denver-snf1.gtei.net!news.gtei.net!namche.sun.com!news2me.EBay.Sun.COM!engnews1.eng.sun.com!taumet!clamage
From: "Geoff Field" <geofffield@hotmail.com>
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: Re: Unsignedness of size_t
Date: 1 May 2002 20:28:17 GMT
Organization: Follow the path if you *must* know
Lines: 63
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <1020129034.890475@cswreg.cos.agilent.com>
References: <3CC7DB8F.52E75D62@bawi.org>
NNTP-Posting-Host: taumet.eng.sun.com
X-NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: Tue, 30 Apr 2002 11:10:29 +1000
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAPNBD80HMCo9UcraBAQGr/QIAsU5dI1GRKjYgsQpq8+sW/QW+1QwnsDge
	T2i5TrVOk8g40eFSZ4P7Jd2UWT+7NhukGr30OznF2kmB/q3SBssn0A==
	=cLxN
X-Approved-For-Group: kuehl@fmi.uni-konstanz.de comp.lang.c++.moderated
X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang)
Content-Length: 2634
X-Status: $$$$
X-UID: 0000000001
Originator: clamage@taumet
Xref: archiver1.google.com comp.std.c++:10950 comp.lang.c++.moderated:42461


"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.
>
> They are just arithmetic quantities, like 'number of people'; no one
> would recommend using unsigned numbers for those kind of quantities.

Why not?  Can one have *negative* numbers of people, or negative sizes?
To my mind, unsigned integral types are the most natural model of a
count of anything "real" - be it people, bytes or bits.

Apart from that, unsigned types on most platforms have an extra bit
available for counting before going to the next size up.  This may not
matter in the hosted world, but for us embedded folks it usually means
adding lots of overhead to drag in another library or set of routines to
handle the bigger data type.

> 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. It also causes many problems
> in arithmetics mixed with signed integers.

Whenever one mixes data types, there's the potential for problems,
whether the mixing is of size or sign or anything else.  Engage brain
before starting to code.

> I know that it is from C and that it's too late to change anything,

There are already some C-isms that have been modified for C++,
but the main problem is that the C++ standard has already been
written (albeit late and in a vastly different form to the original vision
of it).

> but I just want to hear what others have to say.

My take it that it's "horses for courses".  Of course, my background
is low-end embedded systems where *signed* data types can cause
more problems (and code size issues) than unsigned.  Also, I've seen
different libraries used to handle operations with different data sizes.

Geoff

--
Geoff Field,    Professional geek, amateur stage-levelling gauge.
Spamtraps: geofffield@hotmail.com, gcfield@bigmailbox.net, or
geoff_field@great-atuin.co.uk; Real Email: gcfield at optusnet dot com dot
au
My band's web page: http://www.geocities.com/southernarea/




      [ 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                       ]




