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,b257fba0affa289 X-Google-Attributes: gid103376,public From: Al Christians Subject: Re: fixed type (delta) in ada Date: 1999/11/29 Message-ID: <38423E3B.BDE09DFF@easystreet.com>#1/1 X-Deja-AN: 554340537 Content-Transfer-Encoding: 7bit References: <383f6dbb.22609744@news.tstonramp.com> <81pvi5$sl1$1@nnrp1.deja.com> <38409C87.69EC865@easystreet.com> <87n1rzdm4u.fsf@deneb.cygnus.argh.org> <3841B57A.42C70EC0@easystreet.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: typ12.nn.bcandid.com 943865136 206.103.56.138 (Mon, 29 Nov 1999 03:45:36 EST) Organization: Trillium Resources Corporation MIME-Version: 1.0 NNTP-Posting-Date: Mon, 29 Nov 1999 03:45:36 EST Newsgroups: comp.lang.ada Date: 1999-11-29T00:00:00+00:00 List-Id: I don't see anything in Barnes that matches my example very well. I'll guess that the compiler sees Money_Io.Put(351.00 * 0.20) and decides that it has to find a multiplication operator that yields a Money result to match the type of Money_Io.Put's parameter. The only possibility is to multiply two Money's together, so the 351.00 and 0.20 get converted automatically before the multiply, producing the 68.55 result. Money_Io.Put(Money(351.00 * 0.20)) will give the more accurate 70.2 result. Al Preben Randhol wrote: > > Al Christians writes: > > | Next question: I haven't seen where it says that > | > | Money_Io.Put(0.20 * 351.0); > | > | Should put 68.55, which is what GNAT 3.12p does. My guess > | would be that 0.20 * 351.0 should be a static expression of > | type universal real, which should convert to type Money > | equal to 70.2 within +/- 0.01. Is it according to the LRM > | to convert both the 0.20 and 351.0 to the Money type before > | doing the multiply? Any other explanations? > > It has to do with fixed point types and Decimal types (the prior gives > 68.55 the latter gives 70.2). If available see "Programming in Ada 95" > 2.ed by John Barnes (ISBN: 0-201-34293-6) chapter 15.5 and 15.6. > -- > Preben Randhol -- [randhol@pvv.org] -- [http://www.pvv.org/~randhol/] > "Det eneste trygge stedet i verden er inne i en fortelling." > -- Athol Fugard