From: eachus@roadkill.mitre.org (Robert I. Eachus)
Subject: Re: Integer truncation and other recipes
Date: 1996/06/05
Date: 1996-06-05T00:00:00+00:00 [thread overview]
Message-ID: <EACHUS.96Jun5184212@roadkill.mitre.org> (raw)
In-Reply-To: JSA.96May22221027@organon.com
In article <4p4atg$tc5@watnews1.watson.ibm.com> ncohen@watson.ibm.com (Norman H. Cohen) writes:
> Not a very satisfying answer. Suppose you want to delay until the next
> time the minute hand sweeps past the 12. It would be nice to be able to
> write...
> Duration(Float'Floor(Float(Now)/60.0)) is a poor substitute for
> Duration'Floor(Now/60.0).
> I think the failure to generalize certain of the floating-point
> attributes to fixed-point types was an unfortunate oversight.
Agreed. In fact on some implementations:
60.0 * Duration(Integer(Now/Duration'SMALL)/
(60*Integer(1.0/Duration'SMALL)))
Is the only reasonable way to do this due to accuracy issues.
However, that approach depends on (in Ada 83) the UI which says that
1.0 is a model number of Duration. If fact I have had to replace the
divisions by Duration'SMALL by Unchecked_Conversion with some
compilers that simply do not recognize this idiom. (The problem is
not that they do a divide, it's that they do a divide which
overflows...)
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
next prev parent reply other threads:[~1996-06-05 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-22 0:00 Integer truncation and other recipes Paul Shedlarski
1996-05-23 0:00 ` Jon S Anthony
1996-06-04 0:00 ` Jon S Anthony
1996-06-05 0:00 ` Norman H. Cohen
1996-06-04 0:00 ` John English
1996-06-05 0:00 ` Robert I. Eachus [this message]
1996-06-08 0:00 ` Jon S Anthony
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox