comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Fixed-point question
Date: 1995/04/07
Date: 1995-04-07T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.95Apr7192319@spectre.mitre.org> (raw)
In-Reply-To: dewar.797192058@gnat

In article <3m43ot$grt@butch.lmsc.lockheed.com> l107353@cliffy.lfwc.lockheed.com (Garlington KE) writes:

 > Robert Dewar (dewar@cs.nyu.edu) wrote:
 > : On most modern machines floating-point is much faster than fixed-point in
 > : any case. Was there really a good case for using fixed-point in this cas.

   I beg to differ with Professor Dewar on this.  Especially when
32-bit fixed point can be used in preference to 64-bit floating point,
the costs of the added memory accesses dominates...  But even when it
is 32-bits vs. 32-bits, the added costs on processors like the Pentium
can tip the scales.

   However, if you need to do multiplies and divides on some RISC
chips, especially older SPARC implementations, the lack of support for
integer multiply and divide dominates.

 > I've received a couple of replies concerning a "roughly equal" function,
 > and I think everyone so far ran up against the same snags I did. I haven't
 > had time to do any more work on this, but if I do, I'll post the results in
 > case anyone's interested.

   There is no need of a "roughly equal" function with fixed point.
Numbers are either equal or they differ by 'SMALL or greater in both
Ada 83 and Ada 95.

  > To repeat the problem: A user declared a fixed-point type, like

  >   type D is delta 0.1 range ...

  Without a clause defining D'SMALL, D'SMALL is 1/16 (0.0625).

  > This generates a set of model numbers M. In this particular user's mind,
  > however, he is thinking in terms of the set S = { ... 2.0, 2.1, 2.2 ... }
  > (is there a name in Ada for this set?).

  The default display values?  (As far as I know there is no name for
the value set in the programmer's mind.  There might be a name for the
values produced by Text_IO.Fixed_IO.Put.)  The value set {... 2.0,
2.0625, 2.125, 2.1875, ...} is called the model numbers, and is
required to be identical--with the possible exception of one value at
each end if the specified limits are not model mnumbers--on all
compilers.  (The value set for the base type, however, may vary widely
in range from machine to machine or compiler to compiler.)

 > What happened was that he did a calculation that yielded the model
 > number 2.25, which is neither the model number used by the compiler
 > for the literal 2.2 nor the model number for the literal 2.3. What
 > the user wants is a way to map items in M to S, such that the model
 > number for "2.1" will be equal to 2.1, and both 2.25 and the model
 > number for "2.3" will be equal to "2.3". This "roughly equal"
 > function would, ideally, be insensitve to the order of the
 > operands.

   Yes, 2.25 is a model number, as is 2.3125...   The fix of course is
to either use Ada 95 decimal types, or a size clause which sets
D'SMALL to 0.1.

 > If all else fails, I could ask Tartan: their AdaScope debugger does this
 > mapping, such that when X = 2.25, asking the debugger to print out X yields
 > the value "2.3". (This also helped to confuse the user; his code was
 > operating as if X /= 2.3, but the debugger told him X was 2.3!)

   Uh, if they don't support size clauses for 'SMALL, or Ada 95
decimal types you have a problem.  You can use Get and Put on a String
to insure what you want, but it will be slow...

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  parent reply	other threads:[~1995-04-07  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-04-01  0:00 Fixed-point question Garlington KE
1995-04-06  0:00 ` Robert Dewar
1995-04-07  0:00   ` Garlington KE
1995-04-07  0:00     ` Robert Dewar
1995-04-07  0:00   ` Robert I. Eachus [this message]
1995-04-07  0:00     ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2015-06-26 13:20 Patrick Noffke
2015-06-26 16:56 ` Jeffrey R. Carter
2015-06-26 18:21   ` Patrick Noffke
2015-06-26 20:21     ` Anh Vo
2015-06-26 20:25     ` Jeffrey R. Carter
2015-06-27  2:55       ` Patrick Noffke
2015-06-26 23:14     ` Qun-Ying
2015-06-27  3:00       ` Patrick Noffke
2015-06-27  4:44         ` Jeffrey R. Carter
2015-06-27 17:59           ` Patrick Noffke
2015-06-27 18:38             ` Jeffrey R. Carter
2015-06-27 19:20               ` Bob Duff
2015-06-27 19:57                 ` Jeffrey R. Carter
2015-06-27 20:42                   ` Bob Duff
2015-06-28 11:39                     ` Brian Drummond
2015-06-29 13:28                     ` Patrick Noffke
2015-06-29 14:13                       ` Bob Duff
2015-06-27 23:41               ` Anh Vo
replies disabled

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