comp.lang.ada
 help / color / mirror / Atom feed
From: Al Christians <achrist@easystreet.com>
Subject: Re: fixed type (delta) in ada
Date: 1999/11/29
Date: 1999-11-29T00:00:00+00:00	[thread overview]
Message-ID: <38423E3B.BDE09DFF@easystreet.com> (raw)
In-Reply-To: m3ogcdwws5.fsf@kiuk0156.chembio.ntnu.no

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 <achrist@easystreet.com> 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




  reply	other threads:[~1999-11-29  0:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-27  0:00 fixed type (delta) in ada Nap
1999-11-26  0:00 ` Al Christians
1999-11-27  0:00   ` fixed type (delta) in ada and GNAT bug David C. Hoos, Sr.
1999-11-28  0:00 ` fixed type (delta) in ada Nick Roberts
1999-11-30  0:00   ` Simon Wright
1999-11-28  0:00 ` Robert Dewar
1999-11-27  0:00   ` Al Christians
1999-11-28  0:00     ` Florian Weimer
1999-11-28  0:00       ` Al Christians
1999-11-29  0:00         ` Preben Randhol
1999-11-29  0:00           ` Al Christians [this message]
1999-11-29  0:00             ` Preben Randhol
1999-11-28  0:00     ` Preben Randhol
1999-11-29  0:00     ` Robert Dewar
1999-11-29  0:00       ` Al Christians
1999-11-29  0:00         ` Lutz Donnerhacke
1999-11-29  0:00           ` Preben Randhol
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox