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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!ig!agate!ucbvax!NOSC-TECR.ARPA!CONTR47 From: CONTR47@NOSC-TECR.ARPA Newsgroups: comp.lang.ada Subject: Ada decimal elaboration, further experimentation. Message-ID: <8807031845.AA01533@ajpo.sei.cmu.edu> Date: 3 Jul 88 18:49:22 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: Norm Cohen writes: Sam Harbaugh expects the addition in my_dime : dollar_type := 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01; -- 1 2 3 4 5 6 7 8 9 10 to be performed using universal_real addition rather than dollar_type addition. Actually, it is performed using dollar_type addition: Each real literal is implicitly converted to dollar_type and the ten resulting dollar_type values are summed. If Sam had written my_dime : constant := 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01; then exact universal_real addition would have been performed. The Ada rule is that conversion takes place only at the bottom of the expression tree: Only numeric literals, named numbers, and attributes with universal results are convertible. The rule is given in RM paragraph 4.6(15). Paragraph 4.6(20) provides enlightening examples. Norman Cohen IBM Research ------------------------------ Wellll. I tried Norm's suggestion (assuming he meant "constant dollar_type" instead of just "constant") so that my_dime : constant dollar_type := 0.01 + 0.01 etc. for a total of ten 0.01s Janus said my_dime is worth 0.08 Alsys said my_dime is worth 0.10 Dec said my_dime is worth 0.08 How about other people trying this in case I'm missing something and also to see how other compilers handle this. regards,sam harbaugh -------------------