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.204.157.134 with SMTP id b6mr2796690bkx.5.1337667131079; Mon, 21 May 2012 23:12:11 -0700 (PDT) MIME-Version: 1.0 Path: e27ni37470bkw.0!nntp.google.com!news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!news.alt.net!news.dizum.com!sewer-output!mail2news-x3!mail2news-x2!mail2news From: Nomen Nescio Newsgroups: comp.lang.c,comp.lang.ada,comp.lang.fortran Subject: Re: condition true or false? -> (-1 < sizeof("test")) References: Message-ID: Date: Tue, 22 May 2012 08:11:54 +0200 (CEST) Mail-To-News-Contact: abuse@dizum.com Organization: mail2news@dizum.com X-Received-Bytes: 2327 Date: 2012-05-22T08:11:54+02:00 List-Id: glen herrmannsfeldt wrote: > In comp.lang.fortran Nomen Nescio wrote: > (snip) > >> > > Negation of unsigned 1 (which can be written `-1u') is already > >> > > defined in C, although there are implementation-defined aspects. > >> > > In particular, there are no "overflow issues," usual or otherwise. > > Note that in C this is applying the unary - operator to the > constant 1u. > > In Fortran, except in rare cases (the DATA statement being one) > constants are not signed. (The implentation may apply the unary > minus operator before generating the in-memory constant.) > > I would usually write ~0u instead of -1u, but the result is > the same in both cases. > > In Fortran, one could write NOT(0), with the usual restriction > on the bitwise operators on values with the sign bit set. > (In addition to the fact that Fortran doesn't require a binary > representation for data.) > > 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. You can define subtypes of existing types and completely new types and Ada insures you can't make mistakes by mixing apples and oranges. While this is a bit confining at times (when you know it's ok to do so) it does preclude the possibility of something like what Bartc wrote from ever happening. If you know the conversion is ok there are ways (usually by providing an unchecked conversion function) to assign or compare across types.