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: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Portability of Arithmetic (was: Java vs Ada 95) Date: 1996/10/17 Message-ID: #1/1 X-Deja-AN: 190293896 references: <325D7F9B.2A8B@gte.net> <1996Oct15.174526.1@eisner> organization: New York University newsgroups: comp.lang.ada Date: 1996-10-17T00:00:00+00:00 List-Id: Bob Duff says 'True, but it's easy to do it wrong, and have it work just fine, and then find that it doesn't work when you port the code. Do all Ada programmers understand that the above has to be written as you show above? I suspect not. But I suspect all Java programmers understand what the range of int is, and when arithmetic is supposed to work." Harrumph! Arguing that Java programmers know Java and Ada programmers do not know Ada seems to be getting rather thin don't you think? One very important distinction is the following. In either language you can write code where intermediate results are out of range of the type. In both languages, such code may or may not work. In Java, if it does not work, the program execution is (in Ada-ese) erroneous, and who knows what values you get. In Ada, if it does not work, you will get a runtime exception. Arguing that Java arithmetic is more portable seems completely specious to me. The type: type int is range -2**31 .. +2**31-1; is almost exactly equivalent to the Java type int. Why only "almost", well to make it exatly equivalent, I have to do pragma Suppress (Overflow_Check, int); Now it is true that Java guarantees the presence of 64-bit signed binary arithmetic, and Ada does not. However, in my experience, by far the most common need for such high precision arithmetic is in connection with fiscal applications, and here Ada's Decimal type is much more attractive than the use of manually scaled int values.