From: eachus@mitre-bedford.arpa (Robert I. Eachus)
Subject: Re: Don't we already have a 'Valid? (was Re: Unchecked_Conversion...)
Date: 10 Sep 93 20:49:34 GMT [thread overview]
Message-ID: <EACHUS.93Sep10154934@spectre.mitre.org> (raw)
In article <CD59oG.Mru@yktnews.watson.ibm.com> ncohen@watson.ibm.com (Norman H.
Cohen) writes:
> It seemes to me that the 9X RM actually needs a little more
> tinkering to make it work...
I follow Norm's logic, but I can't agree with the conclusion. As
Norm reads the manual right now (and I agree) the following sequence
should either assign true to B or raise PROGRAM_ERROR:
declare
I: Integer := Signalling_NaN;
B: Boolean := False;
S: Short_Float; -- change as necessary for your implementation...
function UC is new Unchecked_Conversion(From => Integer, To => Float);
begin
S := UC(I);
B := Short_Float'VALID(S);
end;
changing the order to:
declare...
begin
B := Short_Float'VALID(UC(I));
S := UC(I);
end;
may change things but doesn't really help. (In fact it is
technically slightly worse. There can be cases where B is assigned
True AND PROGRAM_ERROR is then raised. But I can't imagine a real
instance of this program where the call to UC produced different
results.)
What you really want to be able to say is:
declare...
begin
B := Short_Float'VALID(I);
S := UC(I);
end;
Which would test whether the bits of I are would be a valid value
of type short_float after the Unchecked_Conversion. I'm not
recommending this feature be added to the language, I'm just pointing
out that it probably has a much lower (implementation and run-time)
cost than requiring that B never be stored in a floating point
register until its value is formally accessed.
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
next reply other threads:[~1993-09-10 20:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-09-10 20:49 Robert I. Eachus [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-09-16 17:39 Don't we already have a 'Valid? (was Re: Unchecked_Conversion...) Tucker Taft
1993-09-16 16:25 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
1993-09-13 13:41 Norman H. Cohen
1993-09-10 17:06 Mark A Biggar
1993-09-10 15:07 cis.ohio-state.edu!news.sei.cmu.edu!magnesium.club.cc.cmu.edu!honeydew.sr
1993-09-10 14:00 Mike Berman
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox