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,3ccb707f4c91a5f2 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Portability of Arithmetic (was: Java vs Ada 95) Date: 1996/10/18 Message-ID: #1/1 X-Deja-AN: 190321329 references: <325D7F9B.2A8B@gte.net> <1996Oct17.131142.1@eisner> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-10-18T00:00:00+00:00 List-Id: In article <1996Oct17.131142.1@eisner>, Larry Kilgallen wrote: >In article , bobduff@world.std.com (Robert A Duff) writes: >>> type BT is range 1 .. 200; >>> subtype T is BT range 1 .. 100; >>> X : T := ...; >>> Y : T := ...; >>> Average : T := (X + Y)/2; >I suspect _most_ Ada programmers understand the range of Integer in >their particular environment and know they are not close. But the range of Integer has nothing to do with it. Even if Integer is the 32-bit range, an implementation might well use 8-bit arithmetic for a range like 1..100, and on some machines it might even make sense (80x86, perhaps). I suspect lots of Ada programmers *do* assume that they'll get the same range as Integer for intermediate results, and know that Integer is "plenty" big, and on most compilers, that will work fine. But it's not portably true. - Bob