Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.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: Fri, 27 Jul 2012 08:19:14 -0500 Message-ID: <5012954D.20C@mindspring.com> Date: Fri, 27 Jul 2012 09:19:09 -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: Restricted unsigned integer range would have been better? References: <5011E247.1F7B@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 49 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.219.58 X-Trace: sv3-j9omix7QXSgVx89pruHrGK3HxuCvoYYcrEQMYQmmnWFQMkf+V9N/VYa1NTneQn8vkxBy4JqW7rKxLAH!hp1c/GZS42ZvctLQFeznOvbyF61B9ctapugTkei/9mkDN0aIETLdzkd1lN7IqXTaR+Dagykx6U8G!ldrKtArW 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: 2692 Xref: csiph.com comp.lang.c:23794 Ansel wrote: > > "pete" wrote in message > news:5011E247.1F7B@mindspring.com... > > Ansel wrote: > > > >> If C's unsigned integer types > >> were designed so that their maximum value > >> was the same as the absolute value > >> of the same width signed integer type's minimum value, > >> wouldn't that automagically elimintate > >> a bunch of erroneous code and simplify programming in C? > > > > I have always found > > programming with unsigned integers > > to be simple and easy, > > so your point of view > > is difficult for me to understand. > > > > Mixed-type operations (signed, unsigned) perhaps more complex than > necessary. I think I see what you mean. C is a primative tool. As is typical of primative tools, study and practice goes a long way towards efficacy. Prgrammers who like C, tend to like the primitiveness of it. Mixed type comparisons, is bad C coding style. In the case of the absence of a reason to use a signed type, my default choice for an integer type to use, is an unsigned integer type. I only once recall encountering a mixed type comparison in code which I was maintaining. The mixed type comparison which I encountered, resulted from the wrong choice being made to use type (int), where an unsigned type should have been. The contract that I was working under, required that the code compile without any warnings and the compiler that we were using, emitted a warning for the mixed type comparison, so I changed the (int) type object to an unsigned type. -- pete