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.9 required=5.0 tests=BAYES_00 autolearn=ham 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.68.223.40 with SMTP id qr8mr431326pbc.0.1337709458119; Tue, 22 May 2012 10:57:38 -0700 (PDT) MIME-Version: 1.0 Path: pr3ni28680pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!news.karotte.org!news2.arglkargh.de!news.theremailer.net!frell.theremailer.net!anonymous-x3!anonymous-x2!anonymous From: Fritz Wuehler Comments: This message did not originate from the Sender address above. It was remailed automatically by anonymizing remailer software. Please report problems or inappropriate use to the remailer administrator at . Identifying the real sender is technically impossible. Newsgroups: comp.lang.c,comp.lang.ada,comp.lang.fortran Subject: Re: condition true or false? -> (-1 < sizeof("test")) References: Message-ID: Precedence: anon Date: Tue, 22 May 2012 19:56:13 +0200 Mail-To-News-Contact: abuse@frell.theremailer.net Organization: Frell Anonymous Remailer Date: 2012-05-22T19:56:13+02:00 List-Id: "BartC" wrote: > "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. That's only partially true from an Ada perspective. For one thing, Ada allows you to specify a range for modular types (and for integer types as well) so you (and the compiler) actually know what modulo you are using. In C, if you assign a negative or invalid value to an unsigned int I believe the result you get depends on the C implementation and execution platform. In Ada, the result should be consistent across all implementations and platforms. > 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). I don't agree with this because in many practical cases unsigned integers are more meaningful (counters, for example) and also extend the useful range of machines with small word sizes. If really depends on your application. > That's why it's odd that when there is any hint of a unsigned operand, C > should switch to modular arithmetic for both. I agree. It's the opposite of what you would expect. It seems to me unsigned integers should probably be promoted to signed integer to be the most useful but of course you will also need some way to handle overflows. > 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..