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: 1014db,edd83659ff9286d0 X-Google-NewGroupId: yes X-Google-Thread: 103376,1cd9f7e5a0d12003 X-Google-NewGroupId: yes X-Google-Thread: 1094ba,1cd9f7e5a0d12003 X-Google-NewGroupId: yes X-Google-Attributes: gid4516fb5702,gida07f3367d7,gid8d3408f8c3,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.241.98 with SMTP id wh2mr26403593pbc.7.1337680597180; Tue, 22 May 2012 02:56:37 -0700 (PDT) Path: pr3ni26353pbb.0!nntp.google.com!news1.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 10:55:01 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Date: Tue, 22 May 2012 09:55:26 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="g02lTOQ/PuOntaKLE4vnTw"; logging-data="9124"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sb3qkn2cC7hCXZUlld6Qk" X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726 In-Reply-To: X-Antivirus-Status: Clean X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726 Importance: Normal X-Antivirus: avast! (VPS 120521-1, 21/05/2012), Outbound message Cancel-Lock: sha1:E6EB7PVxLJIIb8UxzMEwW4twUp0= 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-22T10:55:01+01:00 List-Id: "Nomen Nescio" wrote in message news:eb42d1e8b4d1e87bc804d05ec6964bc3@dizum.com... > glen herrmannsfeldt wrote: >> I don't know how ADA treats signed values, or how its bitwise >> operators work. This is still posted to the ADA group, though. > > I'm not an expert on this but Ada is very strongly (statically) typed. > There > are only two integer types in Ada to start with, signed integer and > modular > integer. The compiler will flag an error if you try to compare variables > of > those two types or indeed variables of any differing types. Signed and modular is a better way of explaining how C treats these types, with a clear distinction between them. Signed types clearly should be the primary way to represent actual integer quantities as most of us think of them. A signed integer range can represent any positive value (given enough bits); an unsigned range can't represent any positive or negative value (not with a finite number of bits anyway). That's why it's odd that when there is any hint of a unsigned operand, C should switch to modular arithmetic for both. But, given that C works at a lower level, and the choice of bit-widths is limited, then perhaps there ought to be 3 integer types: - Signed - New-unsigned - Modular 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.. -- Bartc