From 2488646338495746276
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc772,8d9af67f0c48e4ef
X-Google-Attributes: gidfc772,public
X-Google-Thread: f78e5,8d9af67f0c48e4ef
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-05-01 08:35:09 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!chcgil2-snh1.gtei.net!denver-snf1.gtei.net!news.gtei.net!namche.sun.com!news2me.EBay.Sun.COM!engnews1.eng.sun.com!taumet!clamage
From: mkkuhner@kingman.genetics.washington.edu (Mary K. Kuhner)
Newsgroups: comp.std.c++,comp.lang.c++.moderated
Subject: Re: Unsignedness of size_t
Date: 1 May 2002 15:28:06 GMT
Organization: University of Washington Genetics
Lines: 53
Approved: stephen.clamage@sun.com (comp.std.c++)
Message-ID: <aamvks$1q32$1@nntp6.u.washington.edu>
References: <3CC7DB8F.52E75D62@bawi.org>
 <3ccd96e9.5974430@news.ch.kpnqwest.net>
NNTP-Posting-Host: taumet.eng.sun.com
X-NNTP-Posting-Host: netlab.cs.rpi.edu
X-Original-Date: 30 Apr 2002 20:43:08 GMT
X-Submission-Address: c++-submit@netlab.cs.rpi.edu
X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated
	iQBVAwUAPM8vN0HMCo9UcraBAQHCpwIAm5CpnFeWmK8AFKDM+uokQYfW+d8YhaJ/
	8/+nvbLoTgvQEFRLeeBJglcQiUu/y5WaFYLZ8ni9NGbX2w5lUQRgRA==
	=lnbC
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: 2306
X-Status: $$$$
X-UID: 0000000001
Originator: clamage@taumet
Xref: archiver1.google.com comp.std.c++:10936 comp.lang.c++.moderated:42431


In article <3ccd96e9.5974430@news.ch.kpnqwest.net>,
Bob Hairgrove <rhairgroveNoSpam@Pleasebigfoot.com> wrote:

>I believe it has more to do with the appropriateness of the domain ...

>For example, would it be logical to say: "We had -3 guests at our
>house last night"; or: "We need -1.5 liters of milk".

>Such quantites don't make any sense.

But they occur all the time, not in conversation, but in calculation.
How much milk do we need?  5 liters.  How much do we have?  3.5
liters.  So we will have -1.5 liters of milk if we try to carry
out this recipe.

>As to arithmetic, can you give an example where it would be wise (or
>even necessary) to mix signed and unsigned values?

The obvious one that trips me up constantly is that the difference
between two quantities may be negative, even if the quantities
are obligatorily positive.  Say you have two indexes into an array,
and you want to know the distance between them--that needs to be
signed.  Or you want to know how much more milk I have than you have;
the answer will be negative if, in fact, you have more milk.  Avoiding
this takes ugly special-case code.

There is nothing in my current program that would encourage me to
use unsigned at all, were it not for the fact that the STL does and
I need to conform to that at many points.  I hate this; it is a
constant source of small annoying mistakes, and occasional big ones
(where I used unsigned to conform with the STL and then used the
number in a way not appropriate for an unsigned).

My principle is that if I'm so close to the limit of a type that I
would want to use unsigned to make it bigger, I need a bigger type
anyway.  My vote for things to add to C++0x would be long long and
some kind of enormous double, so I wouldn't be spending my life coding
logarithmic work-arounds for too-small types.

Mary Kuhner mkkuhner@gs.washington.edu



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




