Path: utzoo!attcan!uunet!husc6!mailrus!ames!pacbell!att!ucbvax!IBM.COM!NCOHEN From: NCOHEN@IBM.COM (Norman Cohen) Newsgroups: comp.lang.ada Subject: Ada decimal math, an example (or counterexample) Message-ID: <070188.135453.ncohen@ibm.com> Date: 1 Jul 88 17:54:52 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 27 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