From: Nick Roberts <nick.roberts@acm.org>
Subject: Re: Why no 'Floor for fixed point types
Date: Thu, 30 Oct 2003 23:41:25 +0000
Date: 2003-10-30T23:41:25+00:00 [thread overview]
Message-ID: <bns7j9$15h0a9$1@ID-25716.news.uni-berlin.de> (raw)
In-Reply-To: <vq05c5g08vt13@corp.supernews.com>
Randy Brukardt wrote:
>>Do you think fixed point types should have a Floor attribute?
>
> The original answer to this showed that for some fixed point types, it
> wouldn't be possible to implement it accurately. Thus, it is much better to
> show what you are doing via a conversion to an appropriate float type.
> Hopefully the compiler can note the easy cases and eliminate the float
> operations.
To my mind, I would not expect this form of optimisation in any compiler.
Would it not be reasonable to provide 'Floor for fixed-point types which
fulfil certain conditions?
For example, it might be required that the delta be less than 1.0 (and that
the range includes at least one integer). Alternatively, it might be
required that the delta is precisely 1.0 (with conditions on the range).
These conditions might be imposed statically (erroneous) or dynamically
(raising an exception). I suppose the dynamic option would fit easier with
the possibility of the fixed point type being a generic formal.
After all, if Float'Floor(Float(X)) is going to produce a silly result
(without itself raising Constraint_Error), what's wrong with
Some_Fixed'Floor(X) raising Constraint_Error? Surely that would actually be
better?
--
Nick Roberts
next prev parent reply other threads:[~2003-10-30 23:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-23 20:09 Why no 'Floor for fixed point types Duncan Sands
2003-10-23 22:06 ` Robert I. Eachus
2003-10-24 16:00 ` Stephen Leake
2003-10-24 18:13 ` Duncan Sands
2003-10-23 23:10 ` Martin Dowie
2003-10-24 21:46 ` Nick Roberts
2003-10-25 4:29 ` Robert I. Eachus
2003-10-25 20:42 ` Nick Roberts
2003-10-25 22:40 ` Robert I. Eachus
2003-10-27 18:59 ` Randy Brukardt
2003-10-28 1:19 ` Robert I. Eachus
2003-10-28 18:23 ` Nick Roberts
2003-10-28 18:34 ` Stephane Richard
2003-10-29 19:26 ` Randy Brukardt
2003-10-30 4:55 ` Robert I. Eachus
2003-10-28 18:10 ` Nick Roberts
2003-10-27 18:49 ` Randy Brukardt
2003-10-28 18:32 ` Nick Roberts
2003-10-29 19:29 ` Randy Brukardt
2003-10-30 23:41 ` Nick Roberts [this message]
2003-10-31 22:25 ` Randy Brukardt
2003-11-06 2:41 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox