From: eachus@mitre-bedford.arpa (Robert I. Eachus)
Subject: Re: Question on fixed point range constraints
Date: 21 Jul 93 15:31:16 GMT [thread overview]
Message-ID: <EACHUS.93Jul21103116@spectre.mitre.org> (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...
next reply other threads:[~1993-07-21 15:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-07-21 15:31 Robert I. Eachus [this message]
-- strict thread matches above, loose matches on Subject: below --
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox