comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic.brenta@insalien.org>
Subject: Re: float with 24-bit resolution
Date: 21 Aug 2003 01:36:18 +0200
Date: 2003-08-21T01:36:18+02:00	[thread overview]
Message-ID: <m3fzjvsxzh.fsf@insalien.org> (raw)
In-Reply-To: 3F43D1AB.10205@attbi.com

"Robert I. Eachus" <rieachus@attbi.com> writes:

> Martin Dowie wrote:
> 
> > Don't forget that 'fixed-point' is itself sub-divided into 2 categories:
> > 'ordinary'
> > and 'decimal', though I've never found a need for the 'decimal' flavour
> > myself :-)
> 
> It is more of a convenience in declaring decimal fixed point types
> than any inherent difference once the types are created.
> 
> type Dollars is digits 9 delta 0.01;
> 
> on most machines should produce exactly the same type as:
> 
> type Dollars is delta 0.01 range -2.0**31/100..2.0**31/100;
> for Dollars'Small use 0.01;
> 
> But if you are doing financial work it is much clearer.  (It says I
> want a type that corresponds to Cobol +9999999.99.

More important than being clearer, decimal types avoid some rounding
errors that only occur in binary representations.  Some decimal
numbers do not have a finite representation in base 2.  For example,
the number 0.42 (in base 10) becomes 0.01101011100001010001... in base
2.  This is one number that would require an infinite number of bits
to represent exactly, so any calculations made with it would involve
some rounding and loss of precision.  The financial sector is one
particular industry where calculations must be absolutely exact to
some number of decimal, not binary, places.  It is common, there, to
use packed-decimal representations where 4 bits correspond to exactly
1 decimal place.  In packed decimal, 0.42 would become 0.01000010,
requiring a finite number of bits.

-- 
Ludovic Brenta.



  reply	other threads:[~2003-08-20 23:36 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-15 11:59 float with 24-bit resolution mailbox
2003-08-15 12:24 ` Jeffrey Creem
2003-08-15 12:52   ` Adrian Hoe
2003-08-15 12:54     ` Adrian Hoe
2003-08-15 15:01       ` Jeffrey Creem
2003-08-16 15:29         ` Matthew Heaney
2003-08-15 13:39     ` Mark Johnson
2003-08-15 16:56       ` Robert I. Eachus
2003-08-15 18:08         ` Mark Johnson
2003-08-16  3:30           ` Robert I. Eachus
2003-08-18 13:39             ` Mark Johnson
2003-08-20 21:12               ` Robert I. Eachus
2003-08-21 13:38                 ` Mark Johnson
2003-08-16 15:32         ` Matthew Heaney
2003-08-16 15:26     ` Matthew Heaney
2003-08-15 19:56   ` Simon Wright
2003-08-16  4:21     ` Adrian Hoe
2003-08-16 12:59       ` Jeffrey Creem
2003-08-16 15:35     ` Matthew Heaney
2003-08-17 11:40       ` Simon Wright
2003-08-17 13:46         ` Matthew Heaney
2003-08-18  5:05       ` Adrian Hoe
2003-08-18 13:14         ` Matthew Heaney
2003-08-19  3:09           ` Adrian Hoe
2003-08-19 13:00             ` Matthew Heaney
2003-08-30  5:02           ` Randy Brukardt
2003-09-02 16:05             ` Adrian Hoe
2003-09-03  3:31               ` Matthew Heaney
2003-09-03 20:46                 ` Simon Wright
2003-09-04  1:43                   ` Randy Brukardt
2003-09-04  9:53                     ` Jean-Pierre Rosen
2003-09-05  3:46                       ` Randy Brukardt
2003-09-05 17:16                     ` Warren W. Gay VE3WWG
2003-09-05 19:37                       ` Randy Brukardt
2003-09-06 20:48                         ` Warren W. Gay VE3WWG
2003-09-08  7:53                         ` Dmitry A. Kazakov
2003-09-04  1:45                 ` Randy Brukardt
2003-08-16  3:42   ` Robert I. Eachus
2003-08-16 15:38     ` Matthew Heaney
2003-08-16 16:36       ` Robert I. Eachus
2003-08-16 15:22 ` Matthew Heaney
2003-08-17 11:46   ` Simon Wright
2003-08-18 10:04     ` Martin Dowie
2003-08-20 19:53       ` Robert I. Eachus
2003-08-20 23:36         ` Ludovic Brenta [this message]
2003-08-21 13:54           ` Mark Johnson
2003-08-21 14:35             ` Ludovic Brenta
2003-08-22 14:07               ` Mark Johnson
2003-08-22 15:12                 ` Jean-Pierre Rosen
replies disabled

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