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=-0.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,c7f5c70275787af8 X-Google-Attributes: gid103376,public From: aratel@total.net (Andre Ratel) Subject: Re: Ada vs Delphi? Date: 1999/08/11 Message-ID: <37b12a3f.43564067@news.total.net>#1/1 X-Deja-AN: 511369912 References: <37ab421a.5414989@news.total.net> <37ab8bd1.0@news.pacifier.com> <37ae1fc8.653954@news.clara.net> <37AE980F.15E6A15C@maths.unine.ch> X-Complaints-To: abuse@total.net X-Trace: news.total.net 934357496 216.210.29.75 (Wed, 11 Aug 1999 03:44:56 EDT) Organization: TotalNet Inc. NNTP-Posting-Date: Wed, 11 Aug 1999 03:44:56 EDT Newsgroups: comp.lang.ada Date: 1999-08-11T00:00:00+00:00 List-Id: On Mon, 09 Aug 1999 10:57:51 +0200, Gautier 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