comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey Creem" <jeff@thecreems.com>
Subject: Re: float with 24-bit resolution
Date: Fri, 15 Aug 2003 15:01:42 GMT
Date: 2003-08-15T15:01:42+00:00	[thread overview]
Message-ID: <qB6%a.119963$Oz4.25059@rwcrnsc54> (raw)
In-Reply-To: 3f3cd84f$1_2@news.tm.net.my


"Adrian Hoe" <mailbox@nospam.adrianhoe.com.my> wrote in message
news:3f3cd84f$1_2@news.tm.net.my...
>
> Yes, I am trying to talk to some hardware.
>


Ok.... Certainly the fixed point definition I provided approaches a
solution. Complications that you need to think
about and or ignore/document, handle are:

1) Byte Order - The little endian/big endian thing. 24 bit types on little
endian machines talking to big edian H/W  (or vice versa)..
2) Getting the 24 bit type in the first place. How do you get the data from
the HW into memory to work with to start with. It is not
uncommon to have to do 32 bit or 16 bit transfers so you need a method for
getting the data to start with.
3) As another poster mentioned, there is the issue of what you do with the
data once you get it. These fixed point types might be good
as a starting point to get the data into a format that you can begin to work
with but once you start doing calculations on them you will
almost certainly need additional higher resolution fixed point types or
floating point of some precision to do you caculations.

There are more....This is not all that complicated but you do need to think
about this before you start coding.

Also, it may be CRITICAL (depending on what this is used for :) to
understand why we keep harping on the fact that fixed
point types are not floating point types and to understand the limitations
of each.

The basic difference is somewhat highlighted by the way one goes about
starting to declare each of these
types in Ada (although the differences themselves really have nothing at all
to do with Ada per se)

as a first order approximation of the difference, realize that (usually)
fixed point types are implemented using the integer math operations of the
processor while floating point is (usually) implemented using the floating
point unit.

Fixed point numbers always have the same precision (essentially) for all
values that they hold while floating point numbers
have a precision that varies (floats!) depending on the size of the number
involved.

It is best to visualize the underlying representation of these two types (a
working model for your mind, which may not
be exactly (ok..certainly is not the same as) how the compiler implements
it)  as


Fixed point

An Integer (which can vary) and a non-changing LSB that is always the same.
To figure out what value the
fixed point number represents at any given time, multiply (in your mind) the
Integer times the LSB and that is the value that the number
holds.


Floating Point

This can thought of as the computer storing part of the number in a fixed
length string and a separate exponent as a smaller
integer

The_Digits : '.' & String(1 .. 6); -- (Ok total pseudo code here, basically
saying that there is a decimal point followed by some numeric characters)
The_Exponent : Integer range -31 .. 31 (or something like that)

So, one way to store the number 122.1 would be to have "The_Digits" equal to

.1221000 and
The_Exponent = +3

So, as you can see, the float can hold really big or really small numbers
but as they get really big you eventually can  not even
represent digits to the right of the actual decimal point.



In reality (especially for floats) the actual representation and limitations
are much different and even more complicated but one thing you can quickly
see even with this working "model" is that one could easily end up with
floats where

A + B = A
Even when B was non-zero if the exponent of A is enough higher than B.







  reply	other threads:[~2003-08-15 15:01 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 [this message]
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
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