comp.lang.ada
 help / color / mirror / Atom feed
* Question on fixed point range constraints
@ 1993-07-20 17:45 cis.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news
  0 siblings, 0 replies; 2+ messages in thread
From: cis.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news @ 1993-07-20 17:45 UTC (permalink / raw)


I'm trying to create a fixed point type without narrowly
constraining its range. I'd like to use an attribute for
this. Can anyone suggest a way to do this?


i.e  I do not want to do this:

type Velocity is delta 0.01 range -1.0 .. 1.0;

I'd like to do something like this;

type Velocity is delta 0.01 range ?'small .. ?'large;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question on fixed point range constraints
@ 1993-07-21 15:31 Robert I. Eachus
  0 siblings, 0 replies; 2+ messages in thread
From: Robert I. Eachus @ 1993-07-21 15:31 UTC (permalink / raw)


In article <1993Jul20.174520.2243@iplmail.orl.mmc.com> kcronin@orl.mmc.com  wri
tes:

   > I'm trying to create a fixed point type without narrowly
   > constraining its range. I'd like to use an attribute for this.
   > Can anyone suggest a way to do this?

   Sure:

   type Velocity is delta 0.01 range 
       Integer'POS(Integer'FIRST) * 0.01..Integer'POS(Integer'LAST) * 0.01;

   The "trick" behind this is that 'POS returns universal_integer so
the two bounds are of type universal real.  Since they the bounds are
static, they will be evaluated exactly.  Of course if you want the
size of your type to be other than the size of Integer, use another
static integer type.


--

					Robert I. Eachus

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1993-07-21 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-07-20 17:45 Question on fixed point range constraints cis.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news
  -- strict thread matches above, loose matches on Subject: below --
1993-07-21 15:31 Robert I. Eachus

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