comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Roberts <nickroberts@callnetuk.com>
Subject: Re: fixed type (delta) in ada
Date: 1999/11/28
Date: 1999-11-28T00:00:00+00:00	[thread overview]
Message-ID: <384118EF.911A1ABB@callnetuk.com> (raw)
In-Reply-To: 383f6dbb.22609744@news.tstonramp.com

Nap wrote:
> 
> does anyone know why mutiplication between fixed type in ada produce a
> big round off error?
> ...

Do you want the short answer or the long answer, Nap?

The short version of the long answer is: the 'small' chosen for the type
'money' will be a power of two (e.g. 1/128); 0.20 will therefore not
have an exact representation when converted to the type 'money'; this
inexact representation of 0.20 will therefore produce an inexact result
after multiplication.

The short version of the short answer is: use a decimal type instead of
a fixed type (example follows).

   type Money is delta 0.01 digits 11;

Problem solved.

-- 
Nick Roberts
http://www.adapower.com/lab/adaos
Always call for the professionals. (If they don't help, call for me ;-)





  parent reply	other threads:[~1999-11-28  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 ` Nick Roberts [this message]
1999-11-30  0:00   ` fixed type (delta) in ada 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
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