From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 10 Sep 93 20:49:34 GMT From: eachus@mitre-bedford.arpa (Robert I. Eachus) Subject: Re: Don't we already have a 'Valid? (was Re: Unchecked_Conversion...) Message-ID: List-Id: In article 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...