From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, STOX_REPLY_TYPE autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1cd9f7e5a0d12003 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.132.81 with SMTP id a17mr3077026bkt.4.1337703950821; Tue, 22 May 2012 09:25:50 -0700 (PDT) Path: e27ni40446bkw.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: "BartC" Newsgroups: comp.lang.c,comp.lang.ada,comp.lang.fortran Subject: Re: condition true or false? -> (-1 < sizeof("test")) Date: Tue, 22 May 2012 17:25:17 +0100 Organization: A noiseless patient Spider Message-ID: References: <15puwddz4h6cl$.34i9lxveafeb.dlg@40tude.net> Mime-Version: 1.0 Injection-Date: Tue, 22 May 2012 16:25:50 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="g02lTOQ/PuOntaKLE4vnTw"; logging-data="21432"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/INIFtULSQnJ6KeDbPgRy0" X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726 In-Reply-To: <15puwddz4h6cl$.34i9lxveafeb.dlg@40tude.net> X-Antivirus-Status: Clean X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726 Importance: Normal X-Antivirus: avast! (VPS 120522-0, 22/05/2012), Outbound message Cancel-Lock: sha1:56gFLkOpDInWkaKcSVaL5BlWM2A= X-Priority: 3 X-MSMail-Priority: Normal Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Date: 2012-05-22T17:25:17+01:00 List-Id: "Dmitry A. Kazakov" wrote in message news:15puwddz4h6cl$.34i9lxveafeb.dlg@40tude.net... > On Tue, 22 May 2012 10:55:01 +0100, BartC wrote: > >> With the new-unsigned type behaving as I have suggested a few times [in >> the >> original thread in comp.lang.c], just a subrange of a signed type (for >> example, a hypothetical signed integer type that is one bit wider). >> >> With the new-unsigned type, a negation operation must have signed result >> (because, other than -0, it will be negative). While subtraction would >> need >> to be signed too, as results can be negative. And of course there is the >> likelihood of overflow or underflow, for which I will leave to other >> language proposals to deal with.. > > Integer arithmetic is more than just + and -. Did you ask yourself what is > the motivation to have it one bit wider? Yes. So that given 32 bits for example, we can count to approximately 4 billion instead of 2 billion. > The answer is to have + and - > closed. What about *? That would make it x2 bits wider. What about > exponentiation? Much more bits. Factorial? We're talking about C where operations and their results usually have the same predefined width. If it was necessary to worry about worst-cases on every operation, that would make programming at this level pretty much impossible. Instead, that sort of auto-ranging, multi-precision utility is left to higher-level languages, and languages such as C are used to implement them. For that purpose, full-width unsigned arithmetic, preferably with carry status, as available in most processors, is extremely useful. -- Bartc