From: Ludovic Brenta <ludovic.brenta@insalien.org>
Subject: Re: float with 24-bit resolution
Date: 21 Aug 2003 16:35:17 +0200
Date: 2003-08-21T16:35:17+02:00 [thread overview]
Message-ID: <m3brujrsd6.fsf@insalien.org> (raw)
In-Reply-To: 3F44CF31.570ADCFA@raytheon.com
Mark Johnson <mark_h_johnson@raytheon.com> writes:
> Actually, if you look at it carefully, binary can be an acceptable
> alternative - but you must use it in a different manner. For example,
> representing a number with two decimal digits of precision as an integer
> can be done where
> 042 (a value in memory / register)
> is interpreted as
> 0.42
> in calculations and for display to the user. We generated data of that
> type (ages ago) on a machine that had no packed decimal types (nor
> floating point). That machine then sent the data to a "display computer"
> where a software divide by 10 routine (no hardware divide) was used to
> generate the values to display to the user. That method did a few more
> calculations to conserve scarce I/O resources.
>
> For machines where packed decimal is supported, what you say is true,
> but it is not the only alternative. This other way of looking at fixed
> types in general is simply to treat like integers - with a specified
> value as the LSB (not one). In the example above, the LSB is 0.01. The
> compiler still has to work out all the arithmetic operations and side
> effects, but it is feasible.
What you describe is a second-best solution, and by your own accord
you only used it because the target hardware did not support
packed-decimal representations. Your divide-by-10 routine was the
weak point; 10 happens not to be a power of two, and therefore any
division of a binary number by 10 is bound to introduce rounding and
imprecision. You may minimise the impact of that by doing the
division as late as possible, e.g. for display purposes; this is
probably what made the solution acceptable to you. However, if your
program must write to a text file that serves as input to another
program (and then another, etc.), then the loss of precision quickly
becomes unacceptable.
Well, all of this is off-topic; here's a nice way to come back to Ada:
ARM B.4(13), package Interfaces.COBOL:
type Decimal_Element is mod implementation-defined;
type Packed_Decimal is
array (Positive range <>) of Decimal_Element;
pragma Pack(Packed_Decimal);
:)
--
Ludovic Brenta.
next prev parent reply other threads:[~2003-08-21 14:35 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
2003-08-21 13:54 ` Mark Johnson
2003-08-21 14:35 ` Ludovic Brenta [this message]
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