Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 12 May 2011 17:04:42 -0500 Message-ID: <4DCC597D.648C@mindspring.com> Date: Thu, 12 May 2011 18:04:45 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: Would someone tell me if I'm on the wrong track? References: <70cf2865-5c4a-47a5-a8e8-ac369c2b91b3@k22g2000yqh.googlegroups.com> <4dca2cf0$0$18239$4fafbaef@reader2.news.tin.it> <35d5a07f-b868-4f6e-83fd-e333baba79fc@gu8g2000vbb.googlegroups.com> <4DCBCC1F.41A5@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 34 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.223.173 X-Trace: sv3-NxWA+zpoAqPQcVVgCKB0E+WtJcGuOTSVNxZSqH475f8w3J+ij/lk58RBw/nFbGCeSKePlmm1llLZZqw!3+TswkW6ddIhz1OFUWu1/YPoQw6/fZ6SvHzMs7O8H8MiRtY49+jRDhs/p+t8EBEbJ6kyeu2ZGMpr!MIGo3xF6ghw= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2174 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:3842 Seebs wrote: > > On 2011-05-12, pete wrote: > >> unsigned sz; > >> (int) sz < 0 > > >> Does this just check the high bit (assuming 2's complement)? > > > I don't know, > > but I don't see the relevance of ((int) sz < 0). > > The relevance was in that question there. > > On a typical 2s complement system, > it is quite likely that if you convert > a value greater than INT_MAX but no larger than UINT_MAX > to a signed integer type, > you will end up with a negative value. Thus, > sz > INT_MAX > and > (int) sz < 0 > are both fancy ways of saying something much like: > > (sz & ((UNIT_MAX) & ~(UINT_MAX >> 1))) != 0 > > (unless my lack of morning coffee made me get that wrong...) But why would you care about whether or not an unsigned object held a value which was greater than INT_MAX? -- pete