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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7f5c70275787af8 X-Google-Attributes: gid103376,public From: aratel@total.net (Andre Ratel) Subject: Re: Ada vs Delphi? Date: 1999/08/14 Message-ID: <37b54687.54956646@news.total.net>#1/1 X-Deja-AN: 512633146 References: <37ab421a.5414989@news.total.net> <37ab8bd1.0@news.pacifier.com> <37ae1fc8.653954@news.clara.net> <7olfni$jsu$1@nnrp1.deja.com> <37b129ae.43419124@news.total.net> <7os3tj$bao$1@nnrp1.deja.com> X-Complaints-To: abuse@total.net X-Trace: news.total.net 934626918 216.210.29.220 (Sat, 14 Aug 1999 06:35:18 EDT) Organization: TotalNet Inc. NNTP-Posting-Date: Sat, 14 Aug 1999 06:35:18 EDT Newsgroups: comp.lang.ada Date: 1999-08-14T00:00:00+00:00 List-Id: On Wed, 11 Aug 1999 15:13:02 GMT, Ted Dennison wrote: >In article <37b129ae.43419124@news.total.net>, > aratel@total.net (Andre Ratel) wrote: > >> type >> n1, n2: cardinal; >> N21, N12: integer; > >> Now, with the above definitions of variables, a statement like >> N21:= n2 - n1; >> would not be valid with Ada? > >It depends on how "cardinal" is defined. If it were defined as a >completely separate type, eg: > type Cardinal is 0..Integer'max; Sorry, I should have mentioned this. In Delphi, a cardinal is defined as an unsigned 32-bit with range 0 .. 4294967295 whereas an integer is a signed 32-bit with range 2147483648 .. 2147483647. So, yes, cardinal is a completely different type and it contains 0. >then no, that would not be allowed. If you wanted to do that you'd have >to be more explicit about it. eg: > N21 := Cardinal(n2 - n1); Since N21 was declared an integer, I think we should have instead N21:= Integer(n2 -n1); or, to avoid any erroneous results N21:= Integer(n2) - Integer(n1); >However, I could use a "subtype" instead of a completely different >integer type. (I'm not sure if Delphi's "cardinal" includes 0 or not, >but lets assume it does .If not, substitute "Natural" with "Positive" >below). Ada has a predefined subtype of Integer named "Natural" that >achieves the same effect. IAW, the following *is* legal Ada: > n1, n2 : Natural; > > N21 := n2 - n1; If I understand correctly, in Ada, some types have subtypes. So I could declare N21: Integer; n1, n2: Natural; and evaluate the expression N21:= n2 - n1; without problem. That's interesting. Thanks. Andre