From: aratel@total.net (Andre Ratel)
Subject: Re: Ada vs Delphi?
Date: 1999/08/11
Date: 1999-08-11T00:00:00+00:00 [thread overview]
Message-ID: <37b12a3f.43564067@news.total.net> (raw)
In-Reply-To: 37AE980F.15E6A15C@maths.unine.ch
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1445 bytes --]
On Mon, 09 Aug 1999 10:57:51 +0200, Gautier
<gautier.demontmollin@maths.unine.ch> wrote:
>If they have kept compatibility from Turbo Pascal, there is
>a total casting between byte (unsigned_8), short_integer (integer_8),
>word (unsigned_16), integer (integer_16), longint (integer_32)...
>
>The bugs from unsigned <-> signed are the most vicious.
There's also the wrap arounds (so I always keep range checking
enabled.)
>Has this changed in Delphi (read: have they "Adaized" this) ?
Not with Delphi 4 (but version 5 is supposed to get out this
month :-). Here's from the doc of Delphi 4:
"If an operand�s type is a subrange of an integer type,
it is treated as if it were of the integer type."
(Oplg.pdf - Object Pascal Language Guide, p. 4-7)
"Performing arithmetic on signed and unsigned Integers
results in all values being promoted to Int64 to avoid
potential overflow."
(del4new.hlp - Compatibility issues)
I just tried this
<<<<<<<<<<
{$RANGECHECK ON}
var
n1, n2: shortint; {range: -128 .. 127}
N: integer; {range: 2147483648 .. 2147483647}
begin
n1:= 120;
n2:= 120;
N:= n1 + n2;
Writeln(N);
end;
>>>>>>>>>>
The result was, appropriately 240.
Now, if I know that n1 and n2 are both in the range -128..127
while their sum is outside this range, I don't understand what's
wrong with assigning (n1 + n2) to an integer.
Andre
next prev parent reply other threads:[~1999-08-11 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 ` 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 ` Aidan Skinner
1999-08-09 0:00 ` Gautier
1999-08-11 0:00 ` Andre Ratel [this message]
1999-08-12 0:00 ` Gautier
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-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 ` Ted Dennison
1999-08-14 0:00 ` Andre Ratel
1999-08-16 0:00 ` Ted Dennison
1999-08-11 0:00 ` Robert Dewar
1999-08-11 0:00 ` David Botton
1999-08-14 0:00 ` Andre Ratel
1999-08-09 0:00 ` Robert Dewar
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 ` Robert Dewar
1999-08-11 0:00 ` Vladimir Olensky
1999-08-13 0:00 ` Gautier
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-11 0:00 ` Ada vs Delphi? Andre Ratel
1999-08-11 0:00 ` Ada vs Component Pascal (was: Ada vs Delphi?) Ted Dennison
1999-08-11 0:00 ` Ada vs Delphi? Robert Dewar
1999-08-14 0:00 ` 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-07 0:00 ` 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