comp.lang.ada
 help / color / mirror / Atom feed
From: aratel@total.net (Andre Ratel)
Subject: Re: Ada vs Delphi?
Date: 1999/08/14
Date: 1999-08-14T00:00:00+00:00	[thread overview]
Message-ID: <37b54687.54956646@news.total.net> (raw)
In-Reply-To: 7os3tj$bao$1@nnrp1.deja.com

On Wed, 11 Aug 1999 15:13:02 GMT, Ted Dennison <dennison@telepath.com>
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





  reply	other threads:[~1999-08-14  0:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-06  0:00 Ada vs Delphi? Andre Ratel
1999-08-06  0:00 ` William Starner
1999-08-06  0:00   ` William Starner
1999-08-07  0:00   ` tmoran
1999-08-07  0:00     ` Aidan Skinner
1999-08-07  0:00       ` Gautier
1999-08-06  0:00 ` Steve Doiel
1999-08-09  0:00   ` Paul Groves
1999-08-08  0:00     ` Steve Doiel
1999-08-10  0:00       ` Ray Blaak
1999-08-10  0:00         ` Steve Doiel
1999-08-14  0:00           ` Andre Ratel
1999-08-09  0:00     ` Robert Dewar
1999-08-09  0:00     ` Gautier
1999-08-11  0:00       ` Andre Ratel
1999-08-12  0:00         ` Gautier
1999-08-14  0:00           ` Andre Ratel
1999-08-14  0:00             ` Gautier
1999-08-16  0:00               ` Gautier
1999-08-15  0:00             ` Steve Doiel
1999-08-17  0:00             ` Robert I. Eachus
1999-08-12  0:00         ` Gautier
1999-08-09  0:00     ` Aidan Skinner
1999-08-09  0:00     ` Robert Dewar
1999-08-11  0:00       ` Andre Ratel
1999-08-11  0:00         ` Robert Dewar
1999-08-14  0:00           ` Andre Ratel
1999-08-17  0:00             ` Robert I. Eachus
1999-08-11  0:00         ` Robert Dewar
1999-08-11  0:00           ` David Botton
1999-08-14  0:00           ` Andre Ratel
1999-08-11  0:00         ` Ted Dennison
1999-08-14  0:00           ` Andre Ratel [this message]
1999-08-16  0:00             ` Ted Dennison
1999-08-10  0:00     ` Brian Rogoff
1999-08-11  0:00       ` Scientific calculations (was Re: Ada vs Delphi? ) Vladimir Olensky
1999-08-11  0:00         ` Robert Dewar
1999-08-11  0:00           ` Vladimir Olensky
1999-08-13  0:00             ` Robert Dewar
1999-08-13  0:00               ` Brian Rogoff
1999-08-15  0:00               ` Vladimir Olensky
1999-08-15  0:00                 ` Vladimir Olensky
1999-08-13  0:00             ` Gautier
1999-08-11  0:00         ` Robert Dewar
1999-08-11  0:00     ` Ada vs Delphi? Andre Ratel
1999-08-11  0:00       ` Robert Dewar
1999-08-14  0:00         ` Andre Ratel
1999-08-11  0:00       ` Ada vs Component Pascal (was: Ada vs Delphi?) Ted Dennison
1999-08-07  0:00 ` Ada vs Delphi? Gautier
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox