Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!telesoft.UUCP!garym From: garym@telesoft.UUCP (Gary Morris @flash) Newsgroups: comp.lang.ada Subject: Re: Ada decimal math, an example (or counterexample) Message-ID: <8807071558.AA22454@ucsd.edu> Date: 6 Jul 88 18:48:55 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 27 > > type dollar_type is delta 0.01 range 0.00..1000.00; > ... > my_dime : dollar_type := > 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01 + 0.01; > ... These calculations are done using the dollar_type which has a 'small of 0.0078125. For the use you are making of this type, you should use a rep spec to make 'small be the same as the delta. The TeleSoft TeleGen2 compiler supports this: type dollar_type is delta 0.01 range 0.00..1000.00; for dollar_type'small use 0.01; With the rep spec our Sun Ada 1.1 compiler produces the "expected" results: -- my_dime is worth 0.10 --your_dime is worth 0.10 Without the rep spec our Sun Ada 1.1 compiler does the computation using a 'small of 0.0078125 yielding 0.078125, which is rounded to 0.08 for output: -- my_dime is worth 0.08 --your_dime is worth 0.08 Gary Morris UUCP: ucbvax!ucsd!telesoft!garym TeleSoft, San Diego telesoft!garym@ucsd.edu (619) 457-2700 ARPA: ucsd!telesoft!garym@ucbvax.ARPA